uCosminexus Application Server, EJB Container Functionality Guide

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

2.12.8 Precautions when using the Timer Service

This subsection describes the precautions when using the Timer Service.

Organization of this subsection
(1) Specifying the info argument of the createTimer method
(2) Specifying the timeout method in the DD and attribute files
(3) Operation when attempting to acquire a Timer Service object from a Bean that does not support Timer Service objects
(4) Operation specifications of the APIs provided by the TimerService
(5) Precautions during execution of the timeout method

(1) Specifying the info argument of the createTimer method

The getInfo method of the Timer object assumes the object specified in the info argument of the createTimer method of the TimerService object or the info argument of the constructor method of the TimerConfig object as the return value. Therefore, the return value of the getInfo method might be different from the object during the execution of a method such as the createTimer method, and therefore an error might occur.

To prevent this, Hitachi recommends that you set the object specified in the info argument of the createTimer method be invariable, such as a type String or Integer, or do not change the status of the object specified in the info argument. If changed, the return value of the getInfo method will be the object specified after the change.

(2) Specifying the timeout method in the DD and attribute files

When specifying the timeout method in the <method> tag of a DD and the property file, perform either of the followings:

(3) Operation when attempting to acquire a Timer Service object from a Bean that does not support Timer Service objects

The following table describes the methods for acquiring a Timer Service object when the Timer Service is not supported. When attempting to acquire a TimerService object from a Bean or servlet that does not support Timer Service, perform the following operation according to the methods:

Table 2-35 Operation when attempting to acquire a Timer Service object from a Bean that does not support Timer Service objects

Method for acquiring the TimerService objects Operation
EJBContext#getTimerService The IllegalStateException exception is thrown.
JNDI Lookup The NamingException exception is thrown.
DI An attempt to deploy has failed.

Irrespective of whether or not the timeout method is implemented in a Bean that supports the Timer Service, you can acquire the TimerService objects.

(4) Operation specifications of the APIs provided by the TimerService

Of the operations performed during the invocation of an API provided by the TimerService, some operation specifications are not specified clearly in the EJB specifications. The operation specifications of javax.ejb.TimerService and javax.ejb.Timer in Application Server are as follows:

(5) Precautions during execution of the timeout method