uCosminexus Application Server, EJB Container Functionality Guide

[Contents][Glossary][Index][Back][Next]

2.12.3 Automatically generating an EJB timer

This section explains the method of automatically generating an EJB timer. The methods of automatically generating an EJB timer are as follows:

When you use the method of specifying the @Schedule annotation and the Servlet method, you can automatically generate an EJB timer on the startup of an application. You can also automatically generate the EJB timer on the startup of the J2EE server if you enable the automatic start of an application. When you use the Management event method, you can automatically generate the EJB timer on startup of the J2EE server.

Organization of this subsection
(1) Automatically generating an EJB timer on J2EE server startup (Method of specifying the @Schedule annotation)
(2) Automatically generating the EJB timer when starting a J2EE server (servlet method)
(3) Automatically generating the EJB timer when starting a J2EE server (Management event method)

(1) Automatically generating an EJB timer on J2EE server startup (Method of specifying the @Schedule annotation)

You use this method in the case of a Stateless Session Bean and a Singleton Session Bean of EJB 3.1. When an application starts, the EJB container automatically generates a timer based on the @Schedule annotation definition specified in the Session Bean class.

You can generate a timer by specifying the @Schedule annotation in the method of a Bean class that executes processes with the timer, or its parent class. When starting multiple timers, specify the @Schedule annotation.

(2) Automatically generating the EJB timer when starting a J2EE server (servlet method)

This section explains the flow of automatic generation of the EJB timer and its setup when the process of automatically generating an EJB time is implemented in the servlet.

(a) Flow of automatic generation of the EJB timer

The flow in which the servlet method automatically generates an EJB timer is shown below:

Figure 2-23 Flow of automatic generation of the EJB timer (servlet method)

[Figure]

  1. Re-start the J2EE server.
  2. The J2EE application starts automatically.
    The J2EE application that was running when the J2EE server is stopped, starts automatically (the application must be enabled to start automatically).
  3. The init method is executed.
    When the J2EE application starts, the servlet is loaded, and the init method is executed. The init method creates the Enterprise Bean and invokes the business method.
  4. The EJB timer is generated.
    In the business method of the Enterprise Bean, the EJB timer is generated from the Timer Service object.
(b) Setup for automatically generating the EJB timer

Specify the following settings to automatically generate an EJB timer in the servlet:

  1. Create the business method that generates the EJB timer in the Enterprise Bean.
  2. Create the servlet.
    Specify to invoke the business method created in step 1 by the init method.
  3. Load the servlet that is created in step 2 when the J2EE application starts.
    Specify a value of 0 or more as the value of the <load-on-startup> tag of the servlet created in step 2 in the DD (web.xml).
  4. When a J2EE server is started, enable the application to start automatically.

(3) Automatically generating the EJB timer when starting a J2EE server (Management event method)

This section explains the flow of automatic generation of the EJB timer and its setup when the process of automatically generating an EJB timer is set as a Management event.

(a) Flow of automatic generation of the EJB timer

The flow in which the Management event method automatically generates the EJB timer is as follows:

Figure 2-24 Flow of automatic generation of the EJB timer (Management event method)

[Figure]

  1. Re-start the J2EE server.
  2. A message is displayed.
    After a J2EE server has started, the message KDJE30028-I is displayed. The Management event occurs when this message is output.
  3. The Management action is executed.
    The Management event is received and the Management action is executed. The batch file is executed as the Management action.
  4. Batch file is executed.
    The EJB application is executed in the batch file.
  5. The business method is invoked in the EJB client application.
    In the EJB client application, the Enterprise Bean is generated and the business method is invoked.
  6. The EJB timer is generated.
    In the business method of the Enterprise Bean, the EJB timer is generated from the Timer Service object.
(b) Setup for automatically generating the EJB timer

Specify the following settings to automatically generate an EJB timer by using a Management event.

  1. Create the business method that generates the EJB timer in the Enterprise Bean.
  2. Generate the EJB client application.
    Specify to invoke the business method that is created in step 1.
  3. Create the environment and the batch file for executing the EJB client application created in step 2.
  4. Specify to automatically execute the Management event.
    Enable the Management event. For the Management event, specify the message KDJE30028-I that is displayed when a J2EE server starts, and specify the batch file created in step 3 as the management action for this management event.
    For details on the Management events, see 9. Notification of Management Events and Automatic Execution of Processing with Management Actions in the uCosminexus Application Server Operation, Monitoring, and Linkage Guide.