|
IBM WebSphere Application ServerTM Release 8 |
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Provides applications a means to invoke business logic when an application or module is started or stopped.
Application Startup beans enable the invocation of business logic during the starting and stopping of applications (EAR files). These beans must use com.ibm.websphere.startupservice.AppStartUpHome as their home interface and com.ibm.websphere.startupservice.AppStartUp as their remote interface. The user may not extend these interfaces.
Module Startup beans enable the invocation of business logic during the starting and stopping of modules (JAR files). These beans must use com.ibm.websphere.startupservice.ModStartUpHome as their home interface and com.ibm.websphere.startupservice.ModStartUp as their remote interface. The user may not extend these interfaces.
The remote interfaces for both types of startup beans have two methods, start() and stop(). Both methods can utilize any TX_ attribute except for TX_MANDATORY. It is also acceptable if the bean uses bean managed transactions.
An ejb jar in an EAR may contain zero or more of these startup beans of either type. When an application is started, WebSphere will find any session beans that specify the startup bean home and remote interfaces. As each module(JAR) within the application is started, the start() methods on the Module Startup beans associated with this module will be invoked. When the entire application(EAR) has started, the start() methods for each Application Startup bean will be invoked. Each start() method returns a boolean. If the method returns true then the application will continue startup processing normally. If it returns false then the application startup will be aborted. If the start() method throws any exception, then the application start process fails also.
When the application is stopped the stop() methods on all the Module and Application Startup beans will be invoked. This happens the reverse order from the order in which the start() methods were invoked. If the JVM stops suddenly then the stop methods will not be invoked. Any exceptions thrown by a stop method are ignored.
The beans are started in numerically ascending order and are stopped in numerically descending order. This order is applies only within the scope of a single module (JAR). Also, Module and Application Startup beans are handled separately so the order or each type is independant of the other. Modules start prior to Applications and therefore all Module Startup beans will be executed prior to the Application Startup beans. Consider the following example:
Event | What happens |
---|---|
Cluster member on machine #1 starts | The startup bean start() methods are executed on machine #1. |
Cluster member on machine #2 starts | The startup bean start() methods are executed on machine #2. |
Cluster member on machine #3 starts | The startup bean start() methods are executed on machine #3. |
Cluster member on machine #1 stops | The startup bean stop() methods are executed on machine #1. |
Cluster member on machine #1 restarts | The startup bean start() methods are executed on machine #1. |
Cluster member on machine #4 starts | The startup bean start() methods are executed on machine #4. |
If a clustered application needs to execute startup code ONE time before the first cluster member starts then it is best to execute a script that invokes a session bean that contains the start/stop logic. Execute this script prior to starting the clustered application. Likewise, before you stop the clustered application then run another script to execute the application stop code and then shutdown the application. It may be necessary to factor the application into two pieces;
This would allow the 'running code' application to be stopped and then the script can invoke code in the 'start/stop' application. Likewise, at startup then start the 'start/stop' application first, run the script then start the 'running code' application.
|
IBM WebSphere Application ServerTM Release 8 |
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |