|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.myfoo.commonj.timers.FooTimer
public abstract class FooTimer
A FooTimer is returned when a TimerListener is scheduled using one of
the FooTimerManager.schedule methods.
It allows retrieving information about the scheduled TimerListener and
allows cancelling it.
| Field Summary | |
|---|---|
protected long |
period
|
protected long |
scheduledExcecutionTime
|
protected boolean |
stopped
|
| Constructor Summary | |
|---|---|
FooTimer(long startTime,
long period,
commonj.timers.TimerListener listener)
Creates a new instance of FooTimer. |
|
| Method Summary | |
|---|---|
boolean |
cancel()
This cancels the timer and all future TimerListener invocations and may be called during the TimerListener.timerExpired
method. |
protected abstract void |
computeNextExecutionTime()
Compute the next exceution time for this timer. |
void |
execute()
Execute the timer listner. |
long |
getPeriod()
Return the period used to compute the time this timer will repeat. |
long |
getScheduledExecutionTime()
Returns the next absolute scheduled execution time in milliseconds. |
commonj.timers.TimerListener |
getTimerListener()
Returns the application-supplied TimerListener associated with this Timer. |
boolean |
isCancelled()
Getter for cancelled |
boolean |
isExpired()
Check if this timer is expired and needs to be fired. |
void |
stop()
Stop the timer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean stopped
protected long scheduledExcecutionTime
protected long period
| Constructor Detail |
|---|
public FooTimer(long startTime,
long period,
commonj.timers.TimerListener listener)
startTime - start timeperiod - execution periodlistener - the timer listener for this timer.| Method Detail |
|---|
protected abstract void computeNextExecutionTime()
public void execute()
public boolean cancel()
TimerListener.timerExpired
method.
CancelTimerListener.timerCancel events may be
called concurrently with any TimerListener.timerExpired
methods. Proper thread synchronization techiniques must be employed to
ensure consistency.
Once a Timer is cancelled an application must not use the Timer instance again.
cancel in interface commonj.timers.Timertrue if this prevented the next execution
of this timer. false if this was already
cancelled or had already expired in the one shot case.Timer.cancel()
public commonj.timers.TimerListener getTimerListener()
throws java.lang.IllegalStateException
getTimerListener in interface commonj.timers.Timerjava.lang.IllegalStateException - if the TimerManager has been stopped.Timer.getTimerListener()
public long getScheduledExecutionTime()
throws java.lang.IllegalStateException
If invoked while a TimerListener is running, the return value is the scheduled execution time of the current TimerListener execution.
If the timer has been suspended, the time reflects the most recently-calculated execution time prior to being suspended.
getScheduledExecutionTime in interface commonj.timers.Timerjava.lang.IllegalStateException - if the TimerManager has been stopped.Timer.getScheduledExecutionTime()public long getPeriod()
getPeriod in interface commonj.timers.TimerTimer.getPeriod()public boolean isCancelled()
public void stop()
public boolean isExpired()
true if timer is expired.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||