Package org.jboss.as.ejb3.timerservice
Class TimerTask
- java.lang.Object
-
- org.jboss.as.ejb3.timerservice.TimerTask
-
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
CalendarTimerTask
public class TimerTask extends Object implements Runnable
A timer task which will be invoked at appropriate intervals based on aTimerschedule.A
TimerTaskis responsible for invoking the timeout method on the target, through the use ofTimedObjectInvokerFor calendar timers, this
TimerTaskis additionally responsible for creating and scheduling the next round of timer task.- Version:
- $Revision: $
- Author:
- Jaikiran Pai, Wolf-Dieter Fink
-
-
Field Summary
Fields Modifier and Type Field Description protected StringtimedObjectIdprotected StringtimerIdprotected TimerServiceImpltimerServiceTimerServiceImplto which thisTimerTaskbelongs
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DatecalculateNextTimeout(TimerImpl timer)protected voidcallTimeout(TimerImpl timer)voidcancel()protected voidinvokeBeanMethod(TimerImpl timer)protected voidpostTimeoutProcessing(TimerImpl timer)After running the timer calculate the new state or expire the timer and persist it if changed.protected voidretryTimeout(TimerImpl timer)After a timeout failed the timer need to retried.voidrun()Invokes the timeout method through theTimedObjectInvokercorresponding to theTimerImplto which thisTimerTaskbelongs.protected voidscheduleTimeoutIfRequired(TimerImpl timer)
-
-
-
Field Detail
-
timedObjectId
protected final String timedObjectId
-
timerId
protected final String timerId
-
timerService
protected final TimerServiceImpl timerService
TimerServiceImplto which thisTimerTaskbelongs
-
-
Constructor Detail
-
TimerTask
public TimerTask(TimerImpl timer)
Creates aTimerTaskfor the timer- Parameters:
timer- The timer for which this task is being created.- Throws:
IllegalStateException- If the passed timer is null
-
-
Method Detail
-
run
public void run()
Invokes the timeout method through theTimedObjectInvokercorresponding to theTimerImplto which thisTimerTaskbelongs.This method also sets other attributes on the
TimerImplincluding the next timeout of the timer and the timer state.Additionally, for calendar timers, this method even schedules the next timeout timer task before calling the timeout method for the current timeout.
-
scheduleTimeoutIfRequired
protected void scheduleTimeoutIfRequired(TimerImpl timer)
-
invokeBeanMethod
protected void invokeBeanMethod(TimerImpl timer) throws Exception
- Throws:
Exception
-
retryTimeout
protected void retryTimeout(TimerImpl timer) throws Exception
After a timeout failed the timer need to retried. The method must lock the timer for state check and update but not during callTimeout run.- Parameters:
timer- timer to retry and state updates- Throws:
Exception
-
postTimeoutProcessing
protected void postTimeoutProcessing(TimerImpl timer) throws InterruptedException
After running the timer calculate the new state or expire the timer and persist it if changed. The method must lock the timer for state check and updates if overridden.- Parameters:
timer- timer to post processing and persist- Throws:
InterruptedException
-
cancel
public void cancel()
-
-