|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.scheduling.commonj.ScheduledTimerListener
public class ScheduledTimerListener
JavaBean that describes a scheduled TimerListener, consisting of the TimerListener itself (or a Runnable to create a TimerListener for) and a delay plus period. Period needs to be specified; there is no point in a default for it.
The CommonJ TimerManager does not offer more sophisticated scheduling options such as cron expressions. Consider using Quartz for such advanced needs.
Note that the TimerManager uses a TimerListener instance that is shared between repeated executions, in contrast to Quartz which instantiates a new Job for each execution.
TimerListener
,
TimerManager.schedule(commonj.timers.TimerListener, long, long)
,
TimerManager.scheduleAtFixedRate(commonj.timers.TimerListener, long, long)
Constructor Summary | |
---|---|
ScheduledTimerListener()
Create a new ScheduledTimerListener, to be populated via bean properties. |
|
ScheduledTimerListener(Runnable timerTask)
Create a new ScheduledTimerListener, with default one-time execution without delay. |
|
ScheduledTimerListener(Runnable timerTask,
long delay)
Create a new ScheduledTimerListener, with default one-time execution with the given delay. |
|
ScheduledTimerListener(Runnable timerTask,
long delay,
long period,
boolean fixedRate)
Create a new ScheduledTimerListener. |
|
ScheduledTimerListener(commonj.timers.TimerListener timerListener)
Create a new ScheduledTimerListener, with default one-time execution without delay. |
|
ScheduledTimerListener(commonj.timers.TimerListener timerListener,
long delay)
Create a new ScheduledTimerListener, with default one-time execution with the given delay. |
|
ScheduledTimerListener(commonj.timers.TimerListener timerListener,
long delay,
long period,
boolean fixedRate)
Create a new ScheduledTimerListener. |
Method Summary | |
---|---|
long |
getDelay()
Return the delay before starting the job for the first time. |
long |
getPeriod()
Return the period between repeated task executions. |
commonj.timers.TimerListener |
getTimerListener()
Return the TimerListener to schedule. |
boolean |
isFixedRate()
Return whether to schedule as fixed-rate execution. |
boolean |
isOneTimeTask()
Is this task only ever going to execute once? |
void |
setDelay(long delay)
Set the delay before starting the task for the first time, in milliseconds. |
void |
setFixedRate(boolean fixedRate)
Set whether to schedule as fixed-rate execution, rather than fixed-delay execution. |
void |
setPeriod(long period)
Set the period between repeated task executions, in milliseconds. |
void |
setRunnable(Runnable timerTask)
Set the Runnable to schedule as TimerListener. |
void |
setTimerListener(commonj.timers.TimerListener timerListener)
Set the TimerListener to schedule. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ScheduledTimerListener()
setTimerListener(commonj.timers.TimerListener)
,
setDelay(long)
,
setPeriod(long)
,
setFixedRate(boolean)
public ScheduledTimerListener(commonj.timers.TimerListener timerListener)
timerListener
- the TimerListener to schedulepublic ScheduledTimerListener(commonj.timers.TimerListener timerListener, long delay)
timerListener
- the TimerListener to scheduledelay
- the delay before starting the task for the first time (ms)public ScheduledTimerListener(commonj.timers.TimerListener timerListener, long delay, long period, boolean fixedRate)
timerListener
- the TimerListener to scheduledelay
- the delay before starting the task for the first time (ms)period
- the period between repeated task executions (ms)fixedRate
- whether to schedule as fixed-rate executionpublic ScheduledTimerListener(Runnable timerTask)
timerTask
- the Runnable to schedule as TimerListenerpublic ScheduledTimerListener(Runnable timerTask, long delay)
timerTask
- the Runnable to schedule as TimerListenerdelay
- the delay before starting the task for the first time (ms)public ScheduledTimerListener(Runnable timerTask, long delay, long period, boolean fixedRate)
timerTask
- the Runnable to schedule as TimerListenerdelay
- the delay before starting the task for the first time (ms)period
- the period between repeated task executions (ms)fixedRate
- whether to schedule as fixed-rate executionMethod Detail |
---|
public void setRunnable(Runnable timerTask)
DelegatingTimerListener
public void setTimerListener(commonj.timers.TimerListener timerListener)
public commonj.timers.TimerListener getTimerListener()
public void setDelay(long delay)
If the "firstTime" property is specified, this property will be ignored. Specify one or the other, not both.
public long getDelay()
public void setPeriod(long period)
Default is -1, leading to one-time execution. In case of zero or a positive value, the task will be executed repeatedly, with the given interval inbetween executions.
Note that the semantics of the period value vary between fixed-rate and fixed-delay execution.
Note: A period of 0 (for example as fixed delay) is
supported, because the CommonJ specification defines this as a legal value.
Hence a value of 0 will result in immediate re-execution after a job has
finished (not in one-time execution like with java.util.Timer
).
setFixedRate(boolean)
,
isOneTimeTask()
,
TimerManager.schedule(commonj.timers.TimerListener, long, long)
public long getPeriod()
public boolean isOneTimeTask()
true
if this task is only ever going to execute oncegetPeriod()
public void setFixedRate(boolean fixedRate)
See TimerManager javadoc for details on those execution modes.
TimerManager.schedule(commonj.timers.TimerListener, long, long)
,
TimerManager.scheduleAtFixedRate(commonj.timers.TimerListener, long, long)
public boolean isFixedRate()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |