com.caucho.ejb.timer
Class EjbTimerService

java.lang.Object
  extended by com.caucho.ejb.timer.EjbTimerService
All Implemented Interfaces:
TimerService

public class EjbTimerService
extends java.lang.Object
implements TimerService

Resin EJB timer service.


Constructor Summary
EjbTimerService(AbstractEjbBeanManager server)
          Creates a new timer service.
 
Method Summary
 Timer createCalendarTimer(ScheduleExpression schedule)
          Create a calendar-based timer based on the input schedule expression.
 Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig)
          Create a calendar-based timer based on the input schedule expression.
 Timer createIntervalTimer(java.util.Date initialExpiration, long intervalDuration, TimerConfig timerConfig)
          Create an interval timer whose first expiration occurs at a given point in time and whose subsequent expirations occur after a specified interval.
 Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig)
          Create an interval timer whose first expiration occurs after a specified duration, and whose subsequent expirations occur after a specified interval.
 Timer createSingleActionTimer(java.util.Date expiration, TimerConfig timerConfig)
          Create a single-action timer that expires at a given point in time.
 Timer createSingleActionTimer(long duration, TimerConfig timerConfig)
          Create a single-action timer that expires after a specified duration.
 Timer createTimer(java.util.Date initialExpiration, long intervalDuration, java.io.Serializable info)
          Create an interval timer whose first expiration occurs at a given point in time and whose subsequent expirations occur after a specified interval.
 Timer createTimer(java.util.Date expiration, java.io.Serializable info)
          Create a single-action timer that expires at a given point in time.
 Timer createTimer(long initialDuration, long intervalDuration, java.io.Serializable info)
          Create an interval timer whose first expiration occurs after a specified duration, and whose subsequent expirations occur after a specified interval.
 Timer createTimer(long duration, java.io.Serializable info)
          Create a single-action timer that expires after a specified duration.
 java.util.Collection<Timer> getTimers()
          Get all the active timers associated with this bean.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EjbTimerService

public EjbTimerService(AbstractEjbBeanManager server)
Creates a new timer service.

Parameters:
context - EJB context.
Method Detail

createTimer

public Timer createTimer(long duration,
                         java.io.Serializable info)
                  throws java.lang.IllegalArgumentException,
                         java.lang.IllegalStateException,
                         EJBException
Create a single-action timer that expires after a specified duration.

Specified by:
createTimer in interface TimerService
Parameters:
duration - The number of milliseconds that must elapse before the timer expires.
info - Application information to be delivered along with the timer expiration notification. This can be null.
Returns:
The newly created Timer.
Throws:
java.lang.IllegalArgumentException - If duration is negative.
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method fails due to a system-level failure.

createSingleActionTimer

public Timer createSingleActionTimer(long duration,
                                     TimerConfig timerConfig)
                              throws java.lang.IllegalArgumentException,
                                     java.lang.IllegalStateException,
                                     EJBException
Create a single-action timer that expires after a specified duration.

Specified by:
createSingleActionTimer in interface TimerService
Parameters:
duration - The number of milliseconds that must elapse before the timer expires.
timerConfig - Timer configuration.
Returns:
The newly created Timer.
Throws:
java.lang.IllegalArgumentException - If duration is negative.
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method fails due to a system-level failure.

createTimer

public Timer createTimer(long initialDuration,
                         long intervalDuration,
                         java.io.Serializable info)
                  throws java.lang.IllegalArgumentException,
                         java.lang.IllegalStateException,
                         EJBException
Create an interval timer whose first expiration occurs after a specified duration, and whose subsequent expirations occur after a specified interval.

Specified by:
createTimer in interface TimerService
Parameters:
initialDuration - The number of milliseconds that must elapse before the first timer expiration notification.
intervalDuration - The number of milliseconds that must elapse between timer expiration notifications. Expiration notifications are scheduled relative to the time of the first expiration. If expiration is delayed (e.g. due to the interleaving of other method calls on the bean) two or more expiration notifications may occur in close succession to "catch up".
info - Application information to be delivered along with the timer expiration. This can be null.
Returns:
The newly created Timer.
Throws:
java.lang.IllegalArgumentException - If initialDuration is negative, or intervalDuration is negative.
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method could not complete due to a system-level failure.

createIntervalTimer

public Timer createIntervalTimer(long initialDuration,
                                 long intervalDuration,
                                 TimerConfig timerConfig)
                          throws java.lang.IllegalArgumentException,
                                 java.lang.IllegalStateException,
                                 EJBException
Create an interval timer whose first expiration occurs after a specified duration, and whose subsequent expirations occur after a specified interval.

Specified by:
createIntervalTimer in interface TimerService
Parameters:
initialDuration - The number of milliseconds that must elapse before the first timer expiration notification.
intervalDuration - The number of milliseconds that must elapse between timer expiration notifications. Expiration notifications are scheduled relative to the time of the first expiration. If expiration is delayed (e.g. due to the interleaving of other method calls on the bean) two or more expiration notifications may occur in close succession to "catch up".
timerConfig - Timer configuration.
Returns:
The newly created Timer.
Throws:
java.lang.IllegalArgumentException - If initialDuration is negative, or intervalDuration is negative.
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method could not complete due to a system-level failure.

createTimer

public Timer createTimer(java.util.Date expiration,
                         java.io.Serializable info)
                  throws java.lang.IllegalArgumentException,
                         java.lang.IllegalStateException,
                         EJBException
Create a single-action timer that expires at a given point in time.

Specified by:
createTimer in interface TimerService
Parameters:
expiration - The point in time at which the timer must expire.
info - Application information to be delivered along with the timer expiration notification. This can be null.
Returns:
The newly created Timer.
Throws:
java.lang.IllegalArgumentException - If expiration is null, or expiration.getTime() is negative.
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method could not complete due to a system-level failure.

createSingleActionTimer

public Timer createSingleActionTimer(java.util.Date expiration,
                                     TimerConfig timerConfig)
                              throws java.lang.IllegalArgumentException,
                                     java.lang.IllegalStateException,
                                     EJBException
Create a single-action timer that expires at a given point in time.

Specified by:
createSingleActionTimer in interface TimerService
Parameters:
expiration - The point in time at which the timer must expire.
timerConfig - Timer configuration.
Returns:
The newly created Timer.
Throws:
java.lang.IllegalArgumentException - If expiration is null, or expiration.getTime() is negative.
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method could not complete due to a system-level failure.

createTimer

public Timer createTimer(java.util.Date initialExpiration,
                         long intervalDuration,
                         java.io.Serializable info)
                  throws java.lang.IllegalArgumentException,
                         java.lang.IllegalStateException,
                         EJBException
Create an interval timer whose first expiration occurs at a given point in time and whose subsequent expirations occur after a specified interval.

Specified by:
createTimer in interface TimerService
Parameters:
initialExpiration - The point in time at which the first timer expiration must occur.
intervalDuration - The number of milliseconds that must elapse between timer expiration notifications. Expiration notifications are scheduled relative to the time of the first expiration. If expiration is delayed (e.g. due to the interleaving of other method calls on the bean) two or more expiration notifications may occur in close succession to "catch up".
info - Application information to be delivered along with the timer expiration. This can be null.
Returns:
The newly created Timer.
Throws:
java.lang.IllegalArgumentException - If initialExpiration is null, or initialExpiration.getTime() is negative, or intervalDuration is negative.
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method could not complete due to a system-level failure.

createIntervalTimer

public Timer createIntervalTimer(java.util.Date initialExpiration,
                                 long intervalDuration,
                                 TimerConfig timerConfig)
                          throws java.lang.IllegalArgumentException,
                                 java.lang.IllegalStateException,
                                 EJBException
Create an interval timer whose first expiration occurs at a given point in time and whose subsequent expirations occur after a specified interval.

Specified by:
createIntervalTimer in interface TimerService
Parameters:
initialExpiration - The point in time at which the first timer expiration must occur.
intervalDuration - The number of milliseconds that must elapse between timer expiration notifications. Expiration notifications are scheduled relative to the time of the first expiration. If expiration is delayed (e.g. due to the interleaving of other method calls on the bean) two or more expiration notifications may occur in close succession to "catch up".
timerConfig - Timer configuration.
Returns:
The newly created Timer.
Throws:
java.lang.IllegalArgumentException - If initialExpiration is null, or initialExpiration.getTime() is negative, or intervalDuration is negative.
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method could not complete due to a system-level failure.

createCalendarTimer

public Timer createCalendarTimer(ScheduleExpression schedule)
                          throws java.lang.IllegalArgumentException,
                                 java.lang.IllegalStateException,
                                 EJBException
Create a calendar-based timer based on the input schedule expression.

Specified by:
createCalendarTimer in interface TimerService
Parameters:
schedule - A schedule expression describing the timeouts for this timer.
info - Application information to be delivered along with the timer expiration. This can be null.
Returns:
The newly created Timer.
Throws:
java.lang.IllegalArgumentException - If Schedule represents an invalid schedule expression.
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method could not complete due to a system-level failure.

createCalendarTimer

public Timer createCalendarTimer(ScheduleExpression schedule,
                                 TimerConfig timerConfig)
                          throws java.lang.IllegalArgumentException,
                                 java.lang.IllegalStateException,
                                 EJBException
Create a calendar-based timer based on the input schedule expression.

Specified by:
createCalendarTimer in interface TimerService
Parameters:
schedule - A schedule expression describing the timeouts for this timer.
timerConfig - Timer configuration.
Returns:
The newly created Timer.
Throws:
java.lang.IllegalArgumentException - If Schedule represents an invalid schedule expression.
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method could not complete due to a system-level failure.

getTimers

public java.util.Collection<Timer> getTimers()
                                      throws java.lang.IllegalStateException,
                                             EJBException
Get all the active timers associated with this bean.

Specified by:
getTimers in interface TimerService
Returns:
A collection of javax.ejb.Timer objects.
Throws:
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
EJBException - If this method could not complete due to a system-level failure.

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
String representation of the object.