org.jboss.mx.util
Class SchedulableRunnable

java.lang.Object
  extended byorg.jboss.mx.util.SchedulableRunnable
All Implemented Interfaces:
java.lang.Comparable, java.lang.Runnable
Direct Known Subclasses:
MonitorRunnable (src)

public abstract class SchedulableRunnable
extends java.lang.Object
implements java.lang.Comparable, java.lang.Runnable

A schedulable runnable.

Subclasses should implement doRun() to do some real work.

setScheduler(RunnableScheduler) has to be invoked with a RunnableScheduler that has been started for the work to be performed. If the doRun() does not invoke setNextRun(), the link to the scheduler is removed.

See Also:
RunnableScheduler (src)

Constructor Summary
SchedulableRunnable()
          Constructs a new schedulable runnable.
 
Method Summary
 int compareTo(java.lang.Object o)
           
abstract  void doRun()
          Do the work, the scheduled runnable should do its work here
 boolean equals(java.lang.Object obj)
           
 long getNextRun()
          Gets the next run timestamp
 void run()
          Runs doRun()
 void setNextRun(long nextRun)
          Sets the next run date
 RunnableScheduler (src) setScheduler(RunnableScheduler (src)  scheduler)
          Set the scheduler for this runnable
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchedulableRunnable

public SchedulableRunnable()
Constructs a new schedulable runnable.

Method Detail

getNextRun

public long getNextRun()
Gets the next run timestamp

Returns:
the next run

setNextRun

public void setNextRun(long nextRun)
Sets the next run date

If it is linked to a scheduler, it is temporarily removed while the date is modified.

Parameters:
nextRun - the next run date

setScheduler

public RunnableScheduler (src)  setScheduler(RunnableScheduler (src)  scheduler)
Set the scheduler for this runnable

Parameters:
scheduler - pass null to remove the runnable from any scheduler
Returns:
the previous scheduler or null if there was no previous scheduler

doRun

public abstract void doRun()
Do the work, the scheduled runnable should do its work here


run

public final void run()
Runs doRun()

If setNextRun() is not invoked during the doRun(), the link to the scheduler is removed

Specified by:
run in interface java.lang.Runnable

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

equals

public boolean equals(java.lang.Object obj)