org.ow2.jonas.lib.ejb21
Class JTimerService

java.lang.Object
  extended by org.ow2.jonas.lib.ejb21.JTimerService
All Implemented Interfaces:
TimerService

public class JTimerService
extends Object
implements TimerService

JOnAS Implementation of the TimerService interface (from EJB 2.1) One such object is created the first time a bean calls getTimerService. Basically manages the list of the Timers for that bean.

Author:
Philippe Durieux

Constructor Summary
JTimerService(JEntitySwitch es)
          constructor used for Entity beans
JTimerService(JFactory bf)
          constructor used for MDB or Session beans
 
Method Summary
 void cancelAllTimers()
          cancel all timers (when entity bean is removed)
 Timer createTimer(Date initialExpiration, long intervalDuration, 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(Date expiration, Serializable info)
          Create a single-action timer that expires at a given point in time.
 Timer createTimer(long initialDuration, long intervalDuration, 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, Serializable info)
          Create a single-action timer that expires after a specified duration.
 String getContainer()
           
 String getEjbName()
           
 Serializable getPK()
           
 Timer getTimerByTime(long initialDuration, long intervalDuration, Serializable info)
          get a Timer from the list
 Collection getTimers()
          Get all the active timers associated with this bean.
 TransactionManager getTransactionManager()
           
 void notify(Timer timer)
          Notify the timer to the listener
 void remove(Timer timer)
          Remove the Timer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JTimerService

public JTimerService(JFactory bf)
constructor used for MDB or Session beans


JTimerService

public JTimerService(JEntitySwitch es)
constructor used for Entity beans

Method Detail

getTransactionManager

public TransactionManager getTransactionManager()
Returns:
the Transaction Manager

notify

public void notify(Timer timer)
Notify the timer to the listener

Parameters:
timer - The Timer object that will be notified

remove

public void remove(Timer timer)
Remove the Timer

Parameters:
timer - The Timer object that will be removed

cancelAllTimers

public void cancelAllTimers()
cancel all timers (when entity bean is removed)


getTimerByTime

public Timer getTimerByTime(long initialDuration,
                            long intervalDuration,
                            Serializable info)
get a Timer from the list


createTimer

public Timer createTimer(Date initialExpiration,
                         long intervalDuration,
                         Serializable info)
                  throws IllegalArgumentException,
                         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.
info - Application information to be delivered along with the timer expiration. This can be null.
Returns:
the newly created Timer.
Throws:
IllegalArgumentException - initialExpiration = 0, or intervalDuration < 0 or initialExpiration.getTime() < 0.
IllegalStateException - 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(Date expiration,
                         Serializable info)
                  throws IllegalArgumentException,
                         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 expiration must occur.
info - Application information to be delivered along with the timer expiration. This can be null.
Returns:
the newly created Timer.
Throws:
IllegalArgumentException - expiration = 0, or expiration.getTime() < 0.
IllegalStateException - 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(long initialDuration,
                         long intervalDuration,
                         Serializable info)
                  throws IllegalArgumentException,
                         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.
info - Application information to be delivered along with the timer expiration. This can be null.
Returns:
the newly created Timer.
Throws:
IllegalArgumentException - initialExpiration = 0, or intervalDuration < 0.
IllegalStateException - 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(long duration,
                         Serializable info)
                  throws IllegalArgumentException,
                         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. This can be null.
Returns:
the newly created Timer.
Throws:
IllegalArgumentException - initialExpiration = 0, or intervalDuration < 0.
IllegalStateException - 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 Collection getTimers()
                     throws 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:
IllegalStateException - 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.

getEjbName

public String getEjbName()
Returns:
the EjbName used to retrieve the bean factory

getPK

public Serializable getPK()
Returns:
the encoded PK for entity bean timers

getContainer

public String getContainer()
Returns:
the Container File Name


Copyright © 2010 OW2 Consortium. All Rights Reserved.