|
The Spring Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.scheduling.concurrent.ScheduledExecutorTask
public class ScheduledExecutorTask
JavaBean that describes a scheduled executor task, consisting of the Runnable and a delay plus period. Period needs to be specified; there is no point in a default for it.
The JDK 1.5 ScheduledExecutorService does not offer more sophisticated scheduling options such as cron expressions. Consider using Quartz for such advanced needs.
Note that ScheduledExecutorService uses a Runnable instance that is shared between repeated executions, in contrast to Quartz which instantiates a new Job for each execution.
This is the direct analogon of the ScheduledTimerListener class for the JDK 1.3 Timer mechanism.
ScheduledExecutorService.scheduleWithFixedDelay(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit),
ScheduledExecutorService.scheduleAtFixedRate(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit),
ScheduledTimerTask| Constructor Summary | |
|---|---|
ScheduledExecutorTask()
Create a new ScheduledExecutorTask, to be populated via bean properties. |
|
ScheduledExecutorTask(Runnable executorTask)
Create a new ScheduledExecutorTask, with default one-time execution without delay. |
|
ScheduledExecutorTask(Runnable executorTask,
long delay)
Create a new ScheduledExecutorTask, with default one-time execution with the given delay. |
|
ScheduledExecutorTask(Runnable executorTask,
long delay,
long period,
boolean fixedRate)
Create a new ScheduledExecutorTask. |
|
| Method Summary | |
|---|---|
long |
getDelay()
Return the delay before starting the job for the first time. |
long |
getPeriod()
Return the period between repeated task executions. |
Runnable |
getRunnable()
Return the Runnable to schedule as executor task. |
TimeUnit |
getTimeUnit()
Return the time unit for the delay and period values. |
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 executorTask)
Set the Runnable to schedule as executor task. |
void |
setTimeUnit(TimeUnit timeUnit)
Specify the time unit for the delay and period values. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ScheduledExecutorTask()
setDelay(long),
setPeriod(long),
setFixedRate(boolean)public ScheduledExecutorTask(Runnable executorTask)
executorTask - the Runnable to schedule
public ScheduledExecutorTask(Runnable executorTask,
long delay)
executorTask - the Runnable to scheduledelay - the delay before starting the task for the first time (ms)
public ScheduledExecutorTask(Runnable executorTask,
long delay,
long period,
boolean fixedRate)
executorTask - the Runnable 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 execution| Method Detail |
|---|
public void setRunnable(Runnable executorTask)
public Runnable getRunnable()
public void setDelay(long delay)
public long getDelay()
public void setPeriod(long period)
Note that the semantics of the period vary between fixed-rate and fixed-delay execution.
setFixedRate(boolean),
isOneTimeTask()public long getPeriod()
public void setTimeUnit(TimeUnit timeUnit)
TimeUnit.MILLISECONDS).
TimeUnit.MILLISECONDS,
TimeUnit.SECONDSpublic TimeUnit getTimeUnit()
public void setFixedRate(boolean fixedRate)
See ScheduledExecutorService javadoc for details on those execution modes.
ScheduledExecutorService.scheduleWithFixedDelay(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit),
ScheduledExecutorService.scheduleAtFixedRate(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit)public boolean isFixedRate()
public boolean isOneTimeTask()
true if this task is only ever going to execute once.getPeriod()
|
The Spring Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||