DefaultManagedTaskScheduler
@Deprecated
public class ScheduledTimerListener
extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
private long |
delay
Deprecated.
|
private boolean |
fixedRate
Deprecated.
|
private long |
period
Deprecated.
|
private TimerListener |
timerListener
Deprecated.
|
Constructor and Description |
---|
ScheduledTimerListener()
Deprecated.
Create a new ScheduledTimerListener,
to be populated via bean properties.
|
ScheduledTimerListener(TimerListener timerListener)
Deprecated.
Create a new ScheduledTimerListener, with default
one-time execution without delay.
|
ScheduledTimerListener(TimerListener timerListener,
long delay)
Deprecated.
Create a new ScheduledTimerListener, with default
one-time execution with the given delay.
|
ScheduledTimerListener(TimerListener timerListener,
long delay,
long period,
boolean fixedRate)
Deprecated.
Create a new ScheduledTimerListener.
|
Modifier and Type | Method and Description |
---|---|
long |
getDelay()
Deprecated.
Return the delay before starting the job for the first time.
|
long |
getPeriod()
Deprecated.
Return the period between repeated task executions.
|
TimerListener |
getTimerListener()
Deprecated.
Return the TimerListener to schedule.
|
boolean |
isFixedRate()
Deprecated.
Return whether to schedule as fixed-rate execution.
|
boolean |
isOneTimeTask()
Deprecated.
Is this task only ever going to execute once?
|
void |
setDelay(long delay)
Deprecated.
Set the delay before starting the task for the first time,
in milliseconds.
|
void |
setFixedRate(boolean fixedRate)
Deprecated.
Set whether to schedule as fixed-rate execution, rather than
fixed-delay execution.
|
void |
setPeriod(long period)
Deprecated.
Set the period between repeated task executions, in milliseconds.
|
void |
setRunnable(java.lang.Runnable timerTask)
Deprecated.
Set the Runnable to schedule as TimerListener.
|
void |
setTimerListener(TimerListener timerListener)
Deprecated.
Set the TimerListener to schedule.
|
@Nullable private TimerListener timerListener
private long delay
private long period
private boolean fixedRate
public ScheduledTimerListener()
public ScheduledTimerListener(TimerListener timerListener)
timerListener
- the TimerListener to schedulepublic ScheduledTimerListener(TimerListener timerListener, long delay)
timerListener
- the TimerListener to scheduledelay
- the delay before starting the task for the first time (ms)public ScheduledTimerListener(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 void setRunnable(java.lang.Runnable timerTask)
DelegatingTimerListener
public void setTimerListener(@Nullable TimerListener timerListener)
@Nullable public 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 in-between 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()
,
commonj.timers.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.
commonj.timers.TimerManager#schedule(commonj.timers.TimerListener, long, long)
,
commonj.timers.TimerManager#scheduleAtFixedRate(commonj.timers.TimerListener, long, long)
public boolean isFixedRate()