An application server configuration provides settings that control how an application server provides services for running applications and their components.
Why and when to perform this task
To define a hook point to be run when a server or node agent starts and shuts down, you develop a custom service class and then configure a custom service instance. When the application server or node agent starts, the custom service starts and initializes.
Steps for this task
There is a shutdown method for the interface as well. Both methods of the interface declare that they may create an exception, although no specific exception subclass is defined. If an exception is created, the runtime logs it, disables the custom service, and proceeds with starting the server.
On the Custom Service page of the administrative console, click New. Then, on the settings page for a custom service instance, create a custom service configuration for an existing application server or node agent, supplying the name of the class implemented. If your custom service class requires a configuration file, specify the fully-qualified path name to that configuration file in the externalConfigURL field. This file name is passed into your custom service class.
To invoke a native library from the custom service, provide the path name in the Classpath field in addition to the path names that are used to locate the classes and JAR files for the custom service. Doing this adds the path name to the WebSphere Application Server extension classloader, which allows the custom service to locate and correctly load the native library.
If you are developing a custom service for an application server, stop the application server and then restart the server.
If you are developing a custom service for a node agent, stop and then restart the processing of the node agent. On the Node Agents page of the administrative console (System Administration > Node Agents), place a checkmark in the check box beside the node agent you want to stop, then click Stop. To restart the node agent, place a checkmark in the check box beside the node agent, then click Restart.
Check the application server or node agent to ensure that the initialize method of the custom service ran as intended. Also ensure that the shutdown method performs as intended when the server or node agent stops.
Example
ServerInitpublic 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 final java.lang.String externalConfigURLKey = "com.ibm.websphere.runtime.CustomService.externalConfigURLKey"; 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. * * @param configProperties java.util.Properties */ public void shutdown() throws Exception { // Implement shutdown method }
Related concepts
Custom services