Understanding Application Life Cycle Events

10 Programming Application Life Cycle Events 10-1 10 Programming Application Life Cycle Events The following sections describe how to create applications that respond to WebLogic Server application life cycle events: ■ Section 10.1, Understanding Application Life Cycle Events ■ Section 10.2, Registering Events in weblogic-application.xml ■ Section 10.3, Programming Basic Life Cycle Listener Functionality ■ Section 10.4, Examples of Configuring Life Cycle Events with and without the URI Parameter ■ Section 10.5, Understanding Application Life Cycle Event Behavior During Re-deployment ■ Section 10.6, Programming Application Version Life Cycle Events

10.1 Understanding Application Life Cycle Events

Application life cycle listener events provide handles on which developers can control behavior during deployment, undeployment, and redeployment. This section discusses how you can use the application life cycle listener events. Four application life cycle events are provided with WebLogic Server, which can be used to extend listener, shutdown, and startup classes. These include: ■ Listeners—attachable to any event. Possible methods for Listeners are: – public void preStartApplicationLifecycleEvent evt {} The preStart event is the beginning of the prepare phase, or the start of the application deployment process. – public void postStartApplicationLifecycleEvent evt {} The postStart event is the end of the activate phase, or the end of the application deployment process. The application is deployed. – public void preStopApplicationLifecycleEvent evt {} The preStop event is the beginning of the deactivate phase, or the start of the application removal or undeployment process. Note: Application-scoped startup and shutdown classes have been deprecated as of release 9.0 of WebLogic Server. The information in this chapter about startup and shutdown classes is provided only for backwards compatibility. Instead, you should use life cycle listener events in your applications. 10-2 Developing Applications for Oracle WebLogic Server – public void postStopApplicationLifecycleEvent evt {} The postStop event is the end of the remove phase, or the end of the application removal or undeployment process. ■ Shutdown classes only get postStop events. ■ Startup classes only get preStart events.

10.2 Registering Events in weblogic-application.xml