Programming Application Life Cycle Events 10-5
The following example illustrates how you configure application life cycle events without using the URI parameter.
Example 10–5 Configuring Application Life Cycle Events without Using the URI
Parameter
listener listener-classMyListenerlistener-class
listener startup
startup-classMyStartupstartup-class startup
shutdown shutdown-classMyShutdownshutdown-class
shutdown
10.5 Understanding Application Life Cycle Event Behavior During Re-deployment
Application life cycle events are only triggered if a full re-deployment of the application occurs. During a full re-deployment of the application—provided the
application life cycle events have been registered—the application life cycle first commences the shutdown sequence, next re-initializes its classes, and then performs
the startup sequence.
For example, if your listener is registered for the full application life cycle set of events preStart, postStart, preStop, postStop, during a full re-deployment, you see the
following sequence of events:
1.
preStop{}
2.
postStop{}
3.
Initialization takes place. Unless you have set debug flags, you do not see the initialization.
4.
preStart{}
5.
postStart{}
10.6 Programming Application Version Life Cycle Events
The following sections describe how to create applications that respond to WebLogic Server application version life cycle events:
■
Section 10.6.1, Understanding Application Version Life Cycle Event Behavior
■
Section 10.6.2, Types of Application Version Life Cycle Events
■
Section 10.6.3, Example of Production Deployment Sequence When Using Application Version Life Cycle Events
10.6.1 Understanding Application Version Life Cycle Event Behavior
WebLogic Server provides application version life cycle event notifications by allowing you to extend the ApplicationVersionLifecycleListener class and specify a
life cycle listener in weblogic-application.xml. See Appendix A, Enterprise
Application Deployment Descriptor Elements and
Section 10.4, Examples of Configuring Life Cycle Events with and without the URI Parameter
.
10-6 Developing Applications for Oracle WebLogic Server
Application version life cycle events are invoked:
■
For both static and dynamic deployments.
■
Using either anonymous ID or using user identity.
■
Only if the current application is versioned; otherwise, version life cycle events are ignored.
■
for all application versions, including the version that registers the listener. Use the ApplicationVersionLifecycleEvent.isOwnVersion method to determine
if an event belongs to a particular version. See the ApplicationVersionLifecycleEvent class for more information on types of
version life cycle events.
10.6.2 Types of Application Version Life Cycle Events
Four application version life cycle events are provided with WebLogic Server:
■
public void preDeployApplicationVersionLifecycleEvent evt
– The preDeloy event is invoked when an application version deploy or
redeploy operation is initiated.
■
public void postDeployApplicationVersionLifecycleEvent evt
– The postDeloy event is invoked when an application version is deployed or
redeployed successfully.
■
public void preUndeployApplicationVersionLifecycleEvent evt
– The preUndeloy event is invoked when an application version undeploy
operation is initiated.
■
public void postDeleteApplicationVersionLifecycleEvent evt
– The postDelete event is invoked when an application version is deleted.
10.6.3 Example of Production Deployment Sequence When Using Application Version Life Cycle Events