org.jboss.ejb.txtimer
Class TimerServiceImpl

java.lang.Object
  extended byorg.jboss.ejb.txtimer.TimerServiceImpl
All Implemented Interfaces:
TimerService (src)

public class TimerServiceImpl
extends java.lang.Object
implements TimerService (src)

The TimerService provides enterprise bean components with access to the container-provided Timer Service. The EJB Timer Service allows entity beans, stateless session beans, and message-driven beans to be registered for timer callback events at a specified time, after a specified elapsed time, or after a specified interval.

Since:
07-Apr-2004

Constructor Summary
TimerServiceImpl(TimedObjectId (src)  timedObjectId, TimedObjectInvoker (src)  timedObjectInvoker)
          Create a Timer service for the given TimedObject
 
Method Summary
 Timer (src) createTimer(java.util.Date initialExpiration, long intervalDuration, java.io.Serializable info)
          Create an interval txtimer whose first expiration occurs at a given point in time and whose subsequent expirations occur after a specified interval.
 Timer (src) createTimer(java.util.Date expiration, java.io.Serializable info)
          Create a single-action txtimer that expires at a given point in time.
 Timer (src) createTimer(long initialDuration, long intervalDuration, java.io.Serializable info)
          Create an interval txtimer whose first expiration occurs after a specified duration, and whose subsequent expirations occur after a specified interval.
 Timer (src) createTimer(long duration, java.io.Serializable info)
          Create a single-action txtimer that expires after a specified duration.
 java.util.Collection getAllTimers()
          Get the list of all registerd timers, both active and inactive
 TimedObjectInvoker (src) getTimedObjectInvoker()
          Get the TimedObjectInvoker associated with this TimerService
 Timer (src) getTimer(TimerHandle (src)  handle)
          Get the Timer for the given timedObjectId
 java.util.Collection getTimers()
          Get all the active timers associated with this bean.
 Transaction (src) getTransaction()
          Get the current transaction
 void killAllTimers()
          Kill all timers
 void killTimer(TimerHandle (src)  handle)
          Kill the timer for the given handle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimerServiceImpl

public TimerServiceImpl(TimedObjectId (src)  timedObjectId,
                        TimedObjectInvoker (src)  timedObjectInvoker)
Create a Timer service for the given TimedObject

Method Detail

createTimer

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

Specified by:
createTimer in interface TimerService (src)
Parameters:
duration - The number of milliseconds that must elapse before the txtimer expires.
info - Application information to be delivered along with the txtimer 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 (src) - If this method could not complete due to a system-level failure.

createTimer

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

Specified by:
createTimer in interface TimerService (src)
Parameters:
initialDuration - The number of milliseconds that must elapse before the first txtimer expiration notification.
intervalDuration - The number of milliseconds that must elapse between txtimer 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 txtimer expiration notification. 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 (src) - If this method could not complete due to a system-level failure.

createTimer

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

Specified by:
createTimer in interface TimerService (src)
Parameters:
expiration - The point in time at which the txtimer must expire.
info - Application information to be delivered along with the txtimer 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 (src) - If this method could not complete due to a system-level failure.

createTimer

public Timer (src)  createTimer(java.util.Date initialExpiration,
                         long intervalDuration,
                         java.io.Serializable info)
                  throws java.lang.IllegalArgumentException,
                         java.lang.IllegalStateException,
                         EJBException (src) 
Create an interval txtimer 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 (src)
Parameters:
initialExpiration - The point in time at which the first txtimer expiration must occur.
intervalDuration - The number of milliseconds that must elapse between txtimer 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 txtimer expiration notification. 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 (src) - If this method could not complete due to a system-level failure.

getTimers

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

Specified by:
getTimers in interface TimerService (src)
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 (src) - If this method could not complete due to a system-level failure.

getAllTimers

public java.util.Collection getAllTimers()
Get the list of all registerd timers, both active and inactive


getTimer

public Timer (src)  getTimer(TimerHandle (src)  handle)
Get the Timer for the given timedObjectId


killTimer

public void killTimer(TimerHandle (src)  handle)
Kill the timer for the given handle


killAllTimers

public void killAllTimers()
Kill all timers


getTimedObjectInvoker

public TimedObjectInvoker (src)  getTimedObjectInvoker()
Get the TimedObjectInvoker associated with this TimerService


getTransaction

public Transaction (src)  getTransaction()
Get the current transaction