org.mobicents.timers
Class TimerTask

java.lang.Object
  extended by org.mobicents.timers.TimerTask
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
FaultTolerantTimerTimerTask

public abstract class TimerTask
extends java.lang.Object
implements java.lang.Runnable

The base class to implement a task to be scheduled and executed by an FaultTolerantScheduler.

Author:
martins

Field Summary
protected  boolean autoRemoval
          if true the task is removed from the scheduler when it is executed the last time
 
Constructor Summary
TimerTask(TimerTaskData data)
           
 
Method Summary
 void beforeRecover()
          Invoked before a task is recovered, after fail over, by default simply adjust start time if it is a periodic timer.
protected  void cancel()
          Cancels the execution of the task.
 TimerTaskData getData()
          Retrieves the data associated with the task.
 java.util.concurrent.ScheduledFuture<?> getScheduledFuture()
          Retrieves the schedule future object that returns from the task scheduling.
 FaultTolerantScheduler getScheduler()
           
protected  SetTimerAfterTxCommitRunnable getSetTimerTransactionalAction()
          Retrieves the tx action to set the timer when the tx commits, not used in a non tx environment.
protected  void removeFromScheduler()
          Self removal from the scheduler.
 void run()
           
abstract  void runTask()
          The method executed by the scheduler
protected  void setScheduledFuture(java.util.concurrent.ScheduledFuture<?> scheduledFuture)
          Sets the schedule future object that returns from the task scheduling.
 void setScheduler(FaultTolerantScheduler scheduler)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

autoRemoval

protected boolean autoRemoval
if true the task is removed from the scheduler when it is executed the last time

Constructor Detail

TimerTask

public TimerTask(TimerTaskData data)
Parameters:
data -
Method Detail

getData

public TimerTaskData getData()
Retrieves the data associated with the task.

Returns:

getSetTimerTransactionalAction

protected SetTimerAfterTxCommitRunnable getSetTimerTransactionalAction()
Retrieves the tx action to set the timer when the tx commits, not used in a non tx environment.

Returns:

getScheduledFuture

public java.util.concurrent.ScheduledFuture<?> getScheduledFuture()
Retrieves the schedule future object that returns from the task scheduling.

Returns:

setScheduledFuture

protected void setScheduledFuture(java.util.concurrent.ScheduledFuture<?> scheduledFuture)
Sets the schedule future object that returns from the task scheduling.

Parameters:
scheduledFuture -

cancel

protected void cancel()
Cancels the execution of the task. Note, this doesn't remove the task from the scheduler.


run

public final void run()
Specified by:
run in interface java.lang.Runnable

removeFromScheduler

protected void removeFromScheduler()
Self removal from the scheduler. Note that this method does not cancel the task execution.


runTask

public abstract void runTask()
The method executed by the scheduler


beforeRecover

public void beforeRecover()
Invoked before a task is recovered, after fail over, by default simply adjust start time if it is a periodic timer.


setScheduler

public void setScheduler(FaultTolerantScheduler scheduler)
Parameters:
scheduler - the scheduler to set

getScheduler

public FaultTolerantScheduler getScheduler()
Returns:
the scheduler


Copyright © 2011. All Rights Reserved.