Skip to end of metadata
Go to start of metadata

Whadda ya mean Service?

In certain circumstances it is desirable to run a service that is not a servlet as a part of the OpenAM install. Such services are not to be started by the servlet container in response to web requests, but are required to be started when OpenAM starts up and provide their service until such time as OpenAM shuts down. 

Examples of such services are the RADIUS server that was contributed by LDS as a part of OpenAM, which on startup spins up a thread that will listen for incoming RADIUS messages and satisfy RADIUS auth requests. In fact even OpenAM's REST servlet is started by the startup mechanism that is described here, as by default the servlet container may lazily load the REST service that results in a slow response for the first auth request after starting the service. 

How to have your service start when OpenAM starts up.

openam-core's is loaded by the servlet container and can be considered for our purposes as an entry point to OpenAM. It contains some code that utilises Java's ServiceLoader mechanism to load services that implement openam-core's SetupListener interfaces. This means it is possible to have the AMSetupService run a method called addListener() on an implementation of SetupListener after OpenAM has started, loaded its config and is ready for business.

To do this you need to add a file to your project's src/main/resources/META-INF/services directory. The file needs to be named with the interface your service will provide's fully qualified name. In our case that's com.sun.identity.setup.SetupListener. The file should contain the fully qualified name of the class in your project that implements the interface. For example, the openam-radius/openam-radius-server module's com.sun.identity.setup.SetupListener contains;


Which is the class that starts the RADIUS server in OpenAM.

Service Configuration

In order for your service config to be available at start up, its .xml file must be added to openam-service-only's file. 


  • No labels