public class ScheduledTaskRegistrar extends java.lang.Object implements ScheduledTaskHolder, InitializingBean, DisposableBean
TaskScheduler
, typically using cron
expressions.
As of Spring 3.1, ScheduledTaskRegistrar
has a more prominent user-facing
role when used in conjunction with the @EnableAsync
annotation and its
SchedulingConfigurer
callback interface.
EnableAsync
,
SchedulingConfigurer
Constructor and Description |
---|
ScheduledTaskRegistrar() |
Modifier and Type | Method and Description |
---|---|
void |
addCronTask(CronTask task)
Add a
CronTask . |
void |
addCronTask(java.lang.Runnable task,
java.lang.String expression)
Add a Runnable task to be triggered per the given cron expression.
|
void |
addFixedDelayTask(IntervalTask task)
Add a fixed-delay
IntervalTask . |
void |
addFixedDelayTask(java.lang.Runnable task,
long delay)
Add a Runnable task to be triggered with the given fixed delay.
|
void |
addFixedRateTask(IntervalTask task)
Add a fixed-rate
IntervalTask . |
void |
addFixedRateTask(java.lang.Runnable task,
long interval)
Add a
Runnable task to be triggered at the given fixed-rate interval. |
void |
addTriggerTask(java.lang.Runnable task,
Trigger trigger)
Add a Runnable task to be triggered per the given
Trigger . |
void |
addTriggerTask(TriggerTask task)
Add a
TriggerTask . |
void |
afterPropertiesSet()
Calls
scheduleTasks() at bean construction time. |
void |
destroy()
Invoked by the containing
BeanFactory on destruction of a bean. |
java.util.List<CronTask> |
getCronTaskList()
Get the cron tasks as an unmodifiable list of
CronTask objects. |
java.util.List<IntervalTask> |
getFixedDelayTaskList()
Get the fixed-delay tasks as an unmodifiable list of
IntervalTask objects. |
java.util.List<IntervalTask> |
getFixedRateTaskList()
Get the fixed-rate tasks as an unmodifiable list of
IntervalTask objects. |
java.util.Set<ScheduledTask> |
getScheduledTasks()
Return all locally registered tasks that have been scheduled by this registrar.
|
TaskScheduler |
getScheduler()
Return the
TaskScheduler instance for this registrar (may be null ). |
java.util.List<TriggerTask> |
getTriggerTaskList()
Get the trigger tasks as an unmodifiable list of
TriggerTask objects. |
boolean |
hasTasks()
Return whether this
ScheduledTaskRegistrar has any tasks registered. |
ScheduledTask |
scheduleCronTask(CronTask task)
Schedule the specified cron task, either right away if possible
or on initialization of the scheduler.
|
ScheduledTask |
scheduleFixedDelayTask(FixedDelayTask task)
Schedule the specified fixed-delay task, either right away if possible
or on initialization of the scheduler.
|
ScheduledTask |
scheduleFixedDelayTask(IntervalTask task)
Deprecated.
as of 5.0.2, in favor of
scheduleFixedDelayTask(FixedDelayTask) |
ScheduledTask |
scheduleFixedRateTask(FixedRateTask task)
Schedule the specified fixed-rate task, either right away if possible
or on initialization of the scheduler.
|
ScheduledTask |
scheduleFixedRateTask(IntervalTask task)
Deprecated.
as of 5.0.2, in favor of
scheduleFixedRateTask(FixedRateTask) |
protected void |
scheduleTasks()
Schedule all registered tasks against the underlying
task scheduler.
|
ScheduledTask |
scheduleTriggerTask(TriggerTask task)
Schedule the specified trigger task, either right away if possible
or on initialization of the scheduler.
|
void |
setCronTasks(java.util.Map<java.lang.Runnable,java.lang.String> cronTasks)
Specify triggered tasks as a Map of Runnables (the tasks) and cron expressions.
|
void |
setCronTasksList(java.util.List<CronTask> cronTasks)
Specify triggered tasks as a list of
CronTask objects. |
void |
setFixedDelayTasks(java.util.Map<java.lang.Runnable,java.lang.Long> fixedDelayTasks)
Specify triggered tasks as a Map of Runnables (the tasks) and fixed-delay values.
|
void |
setFixedDelayTasksList(java.util.List<IntervalTask> fixedDelayTasks)
Specify fixed-delay tasks as a list of
IntervalTask objects. |
void |
setFixedRateTasks(java.util.Map<java.lang.Runnable,java.lang.Long> fixedRateTasks)
Specify triggered tasks as a Map of Runnables (the tasks) and fixed-rate values.
|
void |
setFixedRateTasksList(java.util.List<IntervalTask> fixedRateTasks)
Specify fixed-rate tasks as a list of
IntervalTask objects. |
void |
setScheduler(java.lang.Object scheduler)
Set the
TaskScheduler to register scheduled tasks with, or a
ScheduledExecutorService to be wrapped as a
TaskScheduler . |
void |
setTaskScheduler(TaskScheduler taskScheduler)
Set the
TaskScheduler to register scheduled tasks with. |
void |
setTriggerTasks(java.util.Map<java.lang.Runnable,Trigger> triggerTasks)
Specify triggered tasks as a Map of Runnables (the tasks) and Trigger objects
(typically custom implementations of the
Trigger interface). |
void |
setTriggerTasksList(java.util.List<TriggerTask> triggerTasks)
Specify triggered tasks as a list of
TriggerTask objects. |
public void setTaskScheduler(TaskScheduler taskScheduler)
TaskScheduler
to register scheduled tasks with.public void setScheduler(@Nullable java.lang.Object scheduler)
TaskScheduler
to register scheduled tasks with, or a
ScheduledExecutorService
to be wrapped as a
TaskScheduler
.@Nullable public TaskScheduler getScheduler()
TaskScheduler
instance for this registrar (may be null
).public void setTriggerTasks(java.util.Map<java.lang.Runnable,Trigger> triggerTasks)
Trigger
interface).public void setTriggerTasksList(java.util.List<TriggerTask> triggerTasks)
TriggerTask
objects. Primarily used
by <task:*>
namespace parsing.ScheduledTasksBeanDefinitionParser
public java.util.List<TriggerTask> getTriggerTaskList()
TriggerTask
objects.null
)public void setCronTasks(java.util.Map<java.lang.Runnable,java.lang.String> cronTasks)
CronTrigger
public void setCronTasksList(java.util.List<CronTask> cronTasks)
CronTask
objects. Primarily used by
<task:*>
namespace parsing.ScheduledTasksBeanDefinitionParser
public java.util.List<CronTask> getCronTaskList()
CronTask
objects.null
)public void setFixedRateTasks(java.util.Map<java.lang.Runnable,java.lang.Long> fixedRateTasks)
public void setFixedRateTasksList(java.util.List<IntervalTask> fixedRateTasks)
IntervalTask
objects. Primarily used
by <task:*>
namespace parsing.ScheduledTasksBeanDefinitionParser
public java.util.List<IntervalTask> getFixedRateTaskList()
IntervalTask
objects.null
)public void setFixedDelayTasks(java.util.Map<java.lang.Runnable,java.lang.Long> fixedDelayTasks)
public void setFixedDelayTasksList(java.util.List<IntervalTask> fixedDelayTasks)
IntervalTask
objects. Primarily used
by <task:*>
namespace parsing.ScheduledTasksBeanDefinitionParser
public java.util.List<IntervalTask> getFixedDelayTaskList()
IntervalTask
objects.null
)public void addTriggerTask(java.lang.Runnable task, Trigger trigger)
Trigger
.public void addTriggerTask(TriggerTask task)
TriggerTask
.TaskScheduler.scheduleAtFixedRate(Runnable, long)
public void addCronTask(java.lang.Runnable task, java.lang.String expression)
public void addFixedRateTask(java.lang.Runnable task, long interval)
Runnable
task to be triggered at the given fixed-rate interval.public void addFixedRateTask(IntervalTask task)
IntervalTask
.TaskScheduler.scheduleAtFixedRate(Runnable, long)
public void addFixedDelayTask(java.lang.Runnable task, long delay)
public void addFixedDelayTask(IntervalTask task)
IntervalTask
.TaskScheduler.scheduleWithFixedDelay(Runnable, long)
public boolean hasTasks()
ScheduledTaskRegistrar
has any tasks registered.public void afterPropertiesSet()
scheduleTasks()
at bean construction time.afterPropertiesSet
in interface InitializingBean
protected void scheduleTasks()
@Nullable public ScheduledTask scheduleTriggerTask(TriggerTask task)
@Nullable public ScheduledTask scheduleCronTask(CronTask task)
null
if processing a previously registered task)@Deprecated @Nullable public ScheduledTask scheduleFixedRateTask(IntervalTask task)
scheduleFixedRateTask(FixedRateTask)
null
if processing a previously registered task)@Nullable public ScheduledTask scheduleFixedRateTask(FixedRateTask task)
null
if processing a previously registered task)@Deprecated @Nullable public ScheduledTask scheduleFixedDelayTask(IntervalTask task)
scheduleFixedDelayTask(FixedDelayTask)
null
if processing a previously registered task)@Nullable public ScheduledTask scheduleFixedDelayTask(FixedDelayTask task)
null
if processing a previously registered task)public java.util.Set<ScheduledTask> getScheduledTasks()
getScheduledTasks
in interface ScheduledTaskHolder
addTriggerTask(java.lang.Runnable, org.springframework.scheduling.Trigger)
,
addCronTask(java.lang.Runnable, java.lang.String)
,
addFixedRateTask(java.lang.Runnable, long)
,
addFixedDelayTask(java.lang.Runnable, long)
public void destroy()
DisposableBean
BeanFactory
on destruction of a bean.destroy
in interface DisposableBean