public class TimerImpl extends Object implements javax.ejb.Timer
Timer| Modifier and Type | Class and Description |
|---|---|
static class |
TimerImpl.Builder |
| Modifier and Type | Field and Description |
|---|---|
protected String |
id
Unique id for this timer instance
|
protected Serializable |
info
The info which was passed while creating the timer.
|
protected Date |
initialExpiration
The initial (first) expiry date of this timer
|
protected long |
intervalDuration
The duration in milli sec.
|
protected Date |
nextExpiration
Next expiry date of this timer
|
protected boolean |
persistent
Indicates whether the timer is persistent
|
protected Date |
previousRun
The date of the previous run of this timer
|
protected Object |
primaryKey
If this is an entity bean then this is the primary key
|
protected TimedObjectInvoker |
timedObjectInvoker
The
TimedObjectInvoker to which this timer corresponds |
protected TimerServiceImpl |
timerService
The
TimerService through which this timer was created |
protected TimerState |
timerState
The timer state
|
| Modifier | Constructor and Description |
|---|---|
protected |
TimerImpl(TimerImpl.Builder builder,
TimerServiceImpl service)
Creates a
TimerImpl |
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertTimerState()
Asserts that the timer is not in any of the following states:
TimerState.CANCELED
TimerState.EXPIRED
|
static TimerImpl.Builder |
builder() |
void |
cancel() |
boolean |
equals(Object o) |
Serializable |
getCachedTimerInfo()
Obtains the timer info cached in memory, without checking the persistent store.
|
protected Thread |
getExecutingThread()
Returns the executing thread which is processing the timeout task
|
javax.ejb.TimerHandle |
getHandle() |
String |
getId()
Returns the id of this timer
|
Serializable |
getInfo() |
Date |
getInitialExpiration()
Returns the initial (first) timeout date of this timer
|
long |
getInterval()
Returns the interval (in milliseconds), between timeouts, of this timer.
|
Date |
getNextExpiration()
This method is similar to
getNextTimeout(), except that this method does not check the timer state
and hence does not throw either IllegalStateException or NoSuchObjectLocalException
or EJBException. |
Date |
getNextTimeout() |
Date |
getPreviousRun()
Returns the
Date of the previous timeout of this timer |
Object |
getPrimaryKey() |
javax.ejb.ScheduleExpression |
getSchedule() |
TimerState |
getState()
Returns the current state of this timer
|
String |
getTimedObjectId()
Returns the timed object id to which this timer belongs
|
long |
getTimeRemaining() |
Serializable |
getTimerInfo()
This method is similar to
getInfo(), except that this method does not check the timer state
and hence does not throw either IllegalStateException or NoSuchObjectLocalException
or EJBException. |
TimerServiceImpl |
getTimerService()
Returns the timer service through which this timer was created
|
protected TimerTask<?> |
getTimerTask()
Returns the task which handles the timeouts of this
TimerImpl |
int |
hashCode() |
void |
invokeOneOff()
Triggers timer, outside of normal expiration.
|
boolean |
isActive()
Returns true if this timer is active.
|
boolean |
isAutoTimer() |
boolean |
isCalendarTimer() |
boolean |
isCanceled()
Returns true if this timer is in
TimerState.CANCELED state. |
boolean |
isExpired()
Returns true if this timer is in
TimerState.EXPIRED state. |
boolean |
isInRetry()
Returns true if this timer is in
TimerState.RETRY_TIMEOUT. |
boolean |
isPersistent() |
void |
lock() |
void |
scheduleTimeout(boolean newTimer)
Creates and schedules a
TimerTask for the next timeout of this timer |
void |
setCachedTimerInfo(Serializable newInfo)
Sets the timer info to a new value.
|
void |
setNextTimeout(Date next)
Sets the next timeout of this timer
|
void |
setPreviousRun(Date previousRun)
Sets the
Date of the previous timeout of this timer |
void |
setTimerState(TimerState state,
Thread thread)
Sets the state and timer task executing thread of this timer
|
void |
suspend()
Suspends any currently scheduled task for this timer
|
String |
toString()
A nice formatted string output for this timer
|
void |
unlock() |
protected final String id
protected volatile TimerState timerState
protected final TimerServiceImpl timerService
TimerService through which this timer was createdprotected final TimedObjectInvoker timedObjectInvoker
TimedObjectInvoker to which this timer correspondsprotected Serializable info
protected final boolean persistent
protected final Date initialExpiration
protected final long intervalDuration
protected final Object primaryKey
protected volatile Date nextExpiration
protected volatile Date previousRun
protected TimerImpl(TimerImpl.Builder builder, TimerServiceImpl service)
TimerImplbuilder - The builder with the timer informationservice - The timer service through which this timer was createdpublic void cancel()
throws IllegalStateException,
javax.ejb.EJBException
cancel in interface javax.ejb.TimerIllegalStateExceptionjavax.ejb.EJBExceptionpublic String getId()
public boolean isCalendarTimer()
throws IllegalStateException,
javax.ejb.EJBException
isCalendarTimer in interface javax.ejb.TimerIllegalStateExceptionjavax.ejb.EJBExceptionpublic javax.ejb.TimerHandle getHandle()
throws IllegalStateException,
javax.ejb.EJBException
getHandle in interface javax.ejb.TimerIllegalStateExceptionjavax.ejb.EJBExceptionpublic boolean isPersistent()
throws IllegalStateException,
javax.ejb.EJBException
isPersistent in interface javax.ejb.TimerIllegalStateExceptionjavax.ejb.EJBExceptionpublic Serializable getInfo() throws IllegalStateException, javax.ejb.EJBException
getInfo in interface javax.ejb.TimerIllegalStateExceptionjavax.ejb.EJBExceptiongetTimerInfo()public Serializable getTimerInfo()
getInfo(), except that this method does not check the timer state
and hence does not throw either IllegalStateException or NoSuchObjectLocalException
or EJBException.public Serializable getCachedTimerInfo()
public void setCachedTimerInfo(Serializable newInfo)
DatabaseTimerPersistence to reset
the cached timer info. It should not be used for other purposes.newInfo - the new timer info, typically null or an empty holder valuepublic Date getNextTimeout() throws IllegalStateException, javax.ejb.EJBException
getNextTimeout in interface javax.ejb.TimerIllegalStateExceptionjavax.ejb.EJBExceptiongetNextExpiration()public Date getNextExpiration()
getNextTimeout(), except that this method does not check the timer state
and hence does not throw either IllegalStateException or NoSuchObjectLocalException
or EJBException.public void setNextTimeout(Date next)
next - The next scheduled timeout of this timerpublic javax.ejb.ScheduleExpression getSchedule()
throws IllegalStateException,
javax.ejb.EJBException
getSchedule in interface javax.ejb.TimerIllegalStateExceptionjavax.ejb.EJBExceptionpublic long getTimeRemaining()
throws IllegalStateException,
javax.ejb.EJBException
getTimeRemaining in interface javax.ejb.TimerIllegalStateExceptionjavax.ejb.EJBExceptionpublic boolean isAutoTimer()
public Date getInitialExpiration()
public long getInterval()
public String getTimedObjectId()
public TimerServiceImpl getTimerService()
public boolean isActive()
A timer is considered to be "active", if its TimerState
is neither of the following:
TimerState.CANCELEDTimerState.EXPIREDpublic boolean isCanceled()
TimerState.CANCELED state. Else returns false.public boolean isExpired()
TimerState.EXPIRED state. Else returns falsepublic boolean isInRetry()
TimerState.RETRY_TIMEOUT. Else returns false.public Date getPreviousRun()
Date of the previous timeout of this timerpublic void setPreviousRun(Date previousRun)
Date of the previous timeout of this timerpreviousRun - public TimerState getState()
protected Thread getExecutingThread()
protected void assertTimerState()
javax.ejb.NoSuchObjectLocalException - if the txtimer was canceled or has expiredpublic void setTimerState(TimerState state, Thread thread)
state - The state of this timerthread - The executing thread which is processing the timeout taskpublic void suspend()
Note that, suspend does not cancel the Timer. Instead,
it just cancels the next scheduled timeout. So once the Timer
is restored (whenever that happens), the Timer will continue to
timeout at appropriate times.
public void invokeOneOff()
throws Exception
Exceptionpublic void scheduleTimeout(boolean newTimer)
TimerTask for the next timeout of this timernewTimer - true if this is a new timer being scheduled, and not a re-schedule due to a timeoutprotected TimerTask<?> getTimerTask()
TimerImplTimerTaskpublic void lock()
throws InterruptedException
InterruptedExceptionpublic void unlock()
public String toString()
public Object getPrimaryKey()
public static TimerImpl.Builder builder()
Copyright © 2022 JBoss by Red Hat. All rights reserved.