uCosminexus Application Server, EJB Container Functionality Guide
This subsection describes the precautions when using the Timer Service.
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.
When specifying the timeout method in the <method> tag of a DD and the property file, perform either of the followings:
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.
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:
Table 2-36 Operation when the javax.ejb.TimerService API is used from the Bean
Implementation of the timeout method | Types of javax.ejb.TimerService methods | |
---|---|---|
createTimer, createCalendarTimer, createIntervalTimer, createSingleActionTimer |
getTimers | |
When the timeout method is implemented# | The EJB timer generation processing is executed. | The EJB timer correction is returned. |
When the timeout method is not implemented | The IllegalStateException exception is thrown. | A blank correction is returned. |
Table 2-37 Operation when the javax.ejb.Timer API is used
Execution of the timeout method | Types of javax.ejb.Timer methods | ||||
---|---|---|---|---|---|
cancel | getHandle, getInfo, isCalendarTimer, getSchedule | getNextTimeout | getTimeRemaining | isPersistent | |
When the timeout method is not executed# | See 2.12.6 Operations of the EJB timer and callback. | Operation is performed according to the specifications. | The timing of occurrence of the next timeout is returned. | The time period until the occurrence of the next timeout is returned. | Always returns false because persistence of the EJB timer is not supported. |
When the timeout method is executed | The time registered as the expected start time of a timeout being executed is returned. | 0 is returned. |
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.