Java Server Lifecycle Modules are Java classes that listen for server lifecycle events in order to perform certain tasks.
The server supports running short or long duration Java-based tasks within the web server environment. These tasks are automatically initiated upon server startup and are notified upon server shutdown. So now you can link tasks such as instantiating singletons and RMI servers.
A brief description of the Server's lifecycle is given below.
init — This phase includes reading configuration, initializing built-in subsystems; naming, security and logging services; and creating the web container.
startup — This phase includes loading and initializing deployed applications
service — The server is ready to service requests
shutdown — This phase stops and destroys loaded applications. The system is preparing to shutdown.
termination — This phase terminates the built-in subsystems and server runtime environment. There won't be any more activity after this phase.
reconfig — The transient server state in which a server thread is dynamically reconfiguring (while the server is in the service state). This phase can occur several times during the life of the server.
Click the Configuration tab and select the configuration you need.
Click Java > Lifecycle Modules tab.
Click New.
Provide values for the following parameters:
Name — Provide a valid unique name for the new lifecycle module.
Enabled — If you want to enable this lifecycle module, use this option.
Class Name — Fully qualified Java class name. The class should implement com.sun.appserv.server.LifecycleListener interface. For more information on using this interface, refer to the Developer's Guide.
Class Path — Optional. You can specify a class path to the listener class.
Load Order — Greater than 100. Order of loading the lifecycle event listeners, in the numerical order. It is recommended to choose a load-order that is greater than or equal to 100 to avoid conflicts with internal lifecycle modules.
On Load Failure — If this option is enabled, the server does not treat exceptions thrown from the listener classes as fatal thus it continues with the normal startup. Disabled by default.
Description — Provide a short description about the lifecycle module.
Properties — Properties can be used to pass arguments to a Java Lifecycle Module. To add a new property, click Add Property button and enter text for name, value and description.
The server lifecycle listener classes are invoked synchronously from the main server thread and hence extra precaution must be taken to ensure that the listener classes do not block the server. The listener classes may create threads if appropriate but they must be stopped during the shutdown/termination phases.
Click the Configuration tab to view the list of configurations and select the configuration you need.
Click Java > Lifecycle Modules tab.
Select the lifecycle module and click Delete Lifecycle Module.
Using CLI
The following example depicts how to create a Java Lifecycle Module named myLifecycleModule for the configuration test, implemented by the class com.MyLifecycleModule.
wadm> create-lifecycle-module --user=admin --password-file=admin.pwd --host=serverhost --port=8989 --config=config1 --class=com.sun.webserver.tests.LifecycleClass LifecycleTest |
See CLI Reference, create-lifecycle-module(1).
To list Java Lifecycle Modules execute the following command:
wadm> list-lifecycle-modules --config=test |
See CLI Reference, list-lifecycle-modules(1).
To add properties to Java Lifecycle Modules, execute the following command:
wadm> create-lifecycle-module-userprop --user=admin --password-file=admin.pwd --host=serverhost --port=8989 --config=config1 --module=LifecycleTest info=Testing |
See CLI Reference, create-lifecycle-module-userprop(1).
To modify Java Lifecycle Module properties, execute the following command:
wadm> set-lifecycle-module-prop --user=admin --password-file=admin.pwd --host=serverhost --port=8989 --config=config1 --module=LifecycleTest class-path=/space |
See CLI Reference, set-lifecycle-module-prop(1)