This subsection describes the invocation order of the server start and stop hook processing when multiple server start and stop hook functionality are registered.
When you start the J2EE server, the serverInitializing method that performs the server start hook processing is invoked in the order in which the classes are registered. Also, when you stop the J2EE server, the serverTerminating method that performs the server stop hook processing is invoked in the reverse of the registered order.
The following figure shows the invocation order of the server start and stop hook functionality when the J2EE server is started normally.
Figure 14-1 Invocation order of the server start and stop hook processing (when the server is started normally)
The three classes A, B, and C implement the server start/ stop hook processing and the classes are assumed to be registered in the order of class A, class B, and class C. With the server start hook processing, if the processing is invoked normally, the classes are invoked in the order of class A, class B, and class C. With the server stop hook processing, the classes are invoked in the order of class C, class B, and class A.
The following figure shows the invocation order of the server start and stop hook functionality when an exception occurs during the server start hook processing.
Figure 14-2 Invocation order of the server start and stop hook processing (when an exception occurs during the start hook processing)
The three classes A, B, and C implement the server start/ stop hook processing and the classes are assumed to be registered in the order of class A, class B, and class C. If an exception occurs during the server start hook processing (serverInitializing method) of class B, the server start hook processing of class C is not invoked. Also, the server stop hook processing is invoked in the order of class B and class A, without invoking the server stop hook processing (serverTerminating method) of class C.
The following figure shows the invocation order of the server start and stop hook functionality when an exception occurs after the execution of the server start hook processing.
Figure 14-3 Invocation order of the server start and stop hook processing (when an exception occurs after the start hook processing)
The three classes A, B, and C implement the server start/ stop hook processing and the classes are assumed to be registered in the order of class A, class B, and class C. If an exception occurs after the execution of the server start hook processing (serverInitializing method) of class B, the server start hook processing of class C is not invoked. Also, the server stop hook processing is not invoked.