You can use the server start and stop hook functionality by implementing the com.hitachi.software.ejb.application.InitTermProcess interface. Implement the server start hook processing in the serverInitializing method and the stop hook processing in the serverTerminating method.
The following is an example of implementing the InitTermProcess interface:
package sample; |
The J2EE server uses the default constructor during the startup to generate an instance of the server start and stop hook functionality. Therefore, specify public in the access specifier of the class and default constructor.
The server stop hook processing is invoked after the stop processing of the application. With the J2EE server, the stop processing is not performed for threads, so the processing threads remain behind, but after the server stop hook processing, a new application is not executed.
Specify the class name for the server start/ stop hook in the property key (ejbserver.application.InitTermProcessClasses) for the server start and stop hook functionality in the user-defined file (usrconf.properties). You can also specify multiple class names for the server start/ stop hook. For details on the user-defined file (usrconf.properties) , see the uCosminexus Application Server Definition Reference Guide.