Oracle GlassFish Server Administration Guide Release 3.1.2 Part Number E24928-01 |
|
|
View PDF |
This chapter provides procedures for administering life cycle modules in the Oracle GlassFish Server 3.1.2 environment.
The following topics are addressed here:
Instructions for accomplishing the tasks in this chapter by using the Administration Console are contained in the Administration Console online help.
Life cycle modules, also known as initialization services, provide a means of running short or long duration Java-based tasks within the GlassFish Server environment. These modules are automatically initiated at server startup and are notified at various phases of the server life cycle. Configured properties for a life cycle module are passed as properties during server initialization.
All life cycle module classes and interfaces are in the as-install/modules/glassfish-api.jar
file.
A life cycle module listens for and performs its tasks in response to the following GlassFish Server sequence of events:
Initialization. The server reads the configuration, initializes built-in subsystems (such as security and logging services), and creates the containers.
Startup. The server loads and initializes deployed applications.
Ready. The server begins servicing requests.
Shutdown. The server shuts down the applications and stops.
Termination. The server closes the containers, the built-in subsystems, and the server runtime environment.
These events are defined in the LifecycleEvent
class. For information on creating life cycle modules, see "Developing Lifecycle Listeners" in Oracle GlassFish Server Application Development Guide.
Note:
If the is-failure-fatal
setting is set to true (the default is false), life cycle module failure prevents server initialization or startup, but not shutdown or termination.
The following topics are addressed here:
Use the create-lifecycle-module
subcommand in remote mode to create a life cycle module.
Ensure that the server is running.
Remote subcommands require a running server.
Create a new life cycle modules by using the create-lifecycle-module
subcommand.
Information about options and properties for the subcommand are included in this help page.
Restart the server for your changes to take effect.
See To Restart a Domain.
Example 10-1 Creating a Life Cycle Module
This example creates the customSetup
life cycle module :
asadmin> create-lifecycle-module --classname "com.acme.CustomSetup" --classpath "/export/customSetup" --loadorder 1 --failurefatal=true --description "this is a sample customSetup" --property rmi="Server\=acme1\:7070":timeout=30 customSetup Command create-lifecycle-module executed successfully
You can also view the full syntax and options of the subcommand by typing asadmin help create-lifecycle-module
at the command line.
Use the list-lifecycle-modules
subcommand in remote mode to list the existing life cycle modules.
Ensure that the server is running.
Remote subcommands require a running server.
List life cycle modules by using the list-lifecycle-modules
subcommand.
Example 10-2 Listing Life Cycle Modules
This example lists the existing life cycle modules.
asadmin> list-lifecycle-modules
WSTCPConnectorLCModule
Command list-lifecycle-modules executed successfully
You can also view the full syntax and options of the subcommand by typing asadmin help list-lifecycle-modules
at the command line.
Use the set
subcommand to update an existing life cycle module.
List the properties that can be updated for a life cycle module by using the get
subcommand.
For example (single mode):
asadmin get "*" | grep sampleLCM applications.application.sampleLCMmodule.availability-enabled=false applications.application.sampleLCMmodule.directory-deployed=false applications.application.sampleLCMmodule.enabled=true applications.application.sampleLCMmodule.name=sampleLCMmodule applications.application.sampleLCMmodule.object-type=user applications.application.sampleLCMmodule.property.class-name=example.lc.SampleModule applications.application.sampleLCMmodule.property.classpath=/build/lcm.jar applications.application.sampleLCMmodule.property.is-failure-fatal=false applications.application.sampleLCMmodule.property.isLifecycle=true
Update a life cycle module by using the set
subcommand.
Restart the server for your changes to take effect.
See To Restart a Domain.
Example 10-3 Updating a Life Cycle Module
This example updates the classpath
property.
sadmin> set applications.application.sampleLCMmodule. property.classpath=/build/lcm_new.jarapplications.application. sampleLCMmodule.property.classpath=/build/lcm_new.jar Command set executed successfully.
You can also view the full syntax and options of the subcommand by typing asadmin help set
at the command line.
Use the delete-lifecycle-module
subcommand in remote mode to delete a life cycle module.
Ensure that the server is running.
Remote subcommands require a running server.
List the current life cycle modules by using the list-lifecycle-modules
subcommand.
Delete a life cycle module by using the delete-lifecycle-module
subcommand.
Example 10-4 Deleting a Life Cycle Module
This example deletes the customSetup
life cycle module.
asadmin> delete-lifecycle-module customSetup
Command delete-lifecycle-module executed successfully
You can also view the full syntax and options of the subcommand by typing asadmin help delete-lifecycle-module
at the command line.