Example: Custom services

Your custom service class must implement the com.ibm.websphere.runtime.CustomService interface. This example assumes that your custom service class needs a configuration file. It shows you how to process the input parameter to get the name of the configuration file. However, if your class does not require a configuration file, the example code that processes the configProperties variable is not needed.

For more information on the CustomService interface, see The com.ibm.websphere.runtime.CustomService interface.

The example class name that implements your custom service is ServerInit.

import com.ibm.websphere.runtime.CustomService;
public class ServerInit implements CustomService
{
/**
* The initialize method is called by the application server run-time when the
* server starts. The Properties object passed to this method must contain all
* configuration information necessary for this service to initialize properly.
*
* @param configProperties java.util.Properties
*/
          
    static String ConfigFileName="";

    public void initialize(java.util.Properties configProperties) throws Exception
    {
        if (configProperties.getProperty(externalConfigURLKey) != null)
        {
           ConfigFileName = configProperties.getProperty(externalConfigURLKey);
        }

       // Implement rest of initialize method
    }
/**
* The shutdown method is called by the application server run-time when the
* server begins its shutdown processing.
*
*/
    public void shutdown() throws Exception
    {
        // Implement shutdown method
    }