org.jboss.ejb.txtimer
Class TimerImpl

java.lang.Object
  extended byorg.jboss.ejb.txtimer.TimerImpl
All Implemented Interfaces:
Synchronization (src) , Timer (src)

public class TimerImpl
extends java.lang.Object
implements Timer (src) , Synchronization (src)

An implementation of an EJB Timer.

Internally it uses a java.util.Timer and maintains its state in a Tx manner.

Since:
07-Apr-2004

Method Summary
 void afterCompletion(int status)
          This method is invoked after the transaction has committed or rolled back.
 void beforeCompletion()
          This method is invoked before the start of the commit or rollback process.
 void cancel()
          Cause the txtimer and all its associated expiration notifications to be cancelled.
 boolean equals(java.lang.Object obj)
          Return true if objectId, createDate, periode are equal
 java.util.Date getFirstTime()
           
 TimerHandle (src) getHandle()
          Get a serializable handle to the txtimer.
 java.io.Serializable getInfo()
          Get the information associated with the txtimer at the time of creation.
 java.io.Serializable getInfoInternal()
           
 long getNextExpire()
           
 java.util.Date getNextTimeout()
          Get the point in time at which the next txtimer expiration is scheduled to occur.
 long getPeriode()
           
 TimedObjectId (src) getTimedObjectId()
           
 long getTimeRemaining()
          Get the number of milliseconds that will elapse before the next scheduled txtimer expiration.
 java.lang.String getTimerId()
           
 int hashCode()
          Hash code based on the Timers invariant properties
 boolean isActive()
           
 boolean isCanceled()
           
 boolean isExpired()
           
 void killTimer()
          Kill the timer, and remove it from the timer service
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getTimerId

public java.lang.String getTimerId()

getTimedObjectId

public TimedObjectId (src)  getTimedObjectId()

getFirstTime

public java.util.Date getFirstTime()

getPeriode

public long getPeriode()

getNextExpire

public long getNextExpire()

getInfoInternal

public java.io.Serializable getInfoInternal()

isActive

public boolean isActive()

isCanceled

public boolean isCanceled()

isExpired

public boolean isExpired()

cancel

public void cancel()
            throws java.lang.IllegalStateException,
                   NoSuchObjectLocalException (src) ,
                   EJBException (src) 
Cause the txtimer and all its associated expiration notifications to be cancelled.

Specified by:
cancel in interface Timer (src)
Throws:
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
NoSuchObjectLocalException (src) - If invoked on a txtimer that has expired or has been cancelled.
EJBException (src) - If this method could not complete due to a system-level failure.

killTimer

public void killTimer()
Kill the timer, and remove it from the timer service


getTimeRemaining

public long getTimeRemaining()
                      throws java.lang.IllegalStateException,
                             NoSuchObjectLocalException (src) ,
                             EJBException (src) 
Get the number of milliseconds that will elapse before the next scheduled txtimer expiration.

Specified by:
getTimeRemaining in interface Timer (src)
Returns:
Number of milliseconds that will elapse before the next scheduled txtimer expiration.
Throws:
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
NoSuchObjectLocalException (src) - If invoked on a txtimer that has expired or has been cancelled.
EJBException (src) - If this method could not complete due to a system-level failure.

getNextTimeout

public java.util.Date getNextTimeout()
                              throws java.lang.IllegalStateException,
                                     NoSuchObjectLocalException (src) ,
                                     EJBException (src) 
Get the point in time at which the next txtimer expiration is scheduled to occur.

Specified by:
getNextTimeout in interface Timer (src)
Returns:
Get the point in time at which the next txtimer expiration is scheduled to occur.
Throws:
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
NoSuchObjectLocalException (src) - If invoked on a txtimer that has expired or has been cancelled.
EJBException (src) - If this method could not complete due to a system-level failure.

getInfo

public java.io.Serializable getInfo()
                             throws java.lang.IllegalStateException,
                                    NoSuchObjectLocalException (src) ,
                                    EJBException (src) 
Get the information associated with the txtimer at the time of creation.

Specified by:
getInfo in interface Timer (src)
Returns:
The Serializable object that was passed in at txtimer creation, or null if the info argument passed in at txtimer creation was null.
Throws:
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
NoSuchObjectLocalException (src) - If invoked on a txtimer that has expired or has been cancelled.
EJBException (src) - If this method could not complete due to a system-level failure.

getHandle

public TimerHandle (src)  getHandle()
                      throws java.lang.IllegalStateException,
                             NoSuchObjectLocalException (src) ,
                             EJBException (src) 
Get a serializable handle to the txtimer. This handle can be used at a later time to re-obtain the txtimer reference.

Specified by:
getHandle in interface Timer (src)
Returns:
Handle of the Timer
Throws:
java.lang.IllegalStateException - If this method is invoked while the instance is in a state that does not allow access to this method.
NoSuchObjectLocalException (src) - If invoked on a txtimer that has expired or has been cancelled.
EJBException (src) - If this method could not complete due to a system-level failure.

equals

public boolean equals(java.lang.Object obj)
Return true if objectId, createDate, periode are equal


hashCode

public int hashCode()
Hash code based on the Timers invariant properties


toString

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


beforeCompletion

public void beforeCompletion()
This method is invoked before the start of the commit or rollback process. The method invocation is done in the context of the transaction that is about to be committed or rolled back.

Specified by:
beforeCompletion in interface Synchronization (src)

afterCompletion

public void afterCompletion(int status)
This method is invoked after the transaction has committed or rolled back.

Specified by:
afterCompletion in interface Synchronization (src)
Parameters:
status - The status of the completed transaction.