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
A timer task which will be invoked at appropriate intervals based on a
Timer
schedule.
A TimerTask is responsible for invoking the timeout method on the target, through
the use of TimedObjectInvoker
For calendar timers, this TimerTask is additionally responsible for creating and
scheduling the next round of timer task.
- Version:
- $Revision: $
- Author:
- Jaikiran Pai, Wolf-Dieter Fink
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Stringprotected final Stringprotected final TimerServiceImplTimerServiceImplto which thisTimerTaskbelongs -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 void
-
Field Details
-
timedObjectId
-
timerId
-
timerService
TimerServiceImplto which thisTimerTaskbelongs
-
-
Constructor Details
-
TimerTask
Creates aTimerTaskfor the timer- Parameters:
timer- The timer for which this task is being created.- Throws:
IllegalStateException- If the passed timer is null
-
-
Method Details
-
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
-
callTimeout
- Throws:
Exception
-
invokeBeanMethod
- Throws:
Exception
-
calculateNextTimeout
-
retryTimeout
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
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()
-