类 ScheduledTaskRegistrar
java.lang.Object
cn.taketoday.scheduling.config.ScheduledTaskRegistrar
- 所有已实现的接口:
DisposableBean,InitializingBean,ScheduledTaskHolder
public class ScheduledTaskRegistrar
extends Object
implements ScheduledTaskHolder, InitializingBean, DisposableBean
Helper bean for registering tasks with a
TaskScheduler, typically using cron
expressions.
ScheduledTaskRegistrar has a more prominent user-facing
role when used in conjunction with the @EnableAsync annotation and its
SchedulingConfigurer callback interface.
- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller, Chris Beams, Tobias Montagna-Hay, Sam Brannen
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明static final StringA special cron expression value that indicates a disabled trigger: "-". -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidaddCronTask(CronTask task) Add aCronTask.voidaddCronTask(Runnable task, String expression) Add aRunnabletask to be triggered per the given cronexpression.voidAdd a fixed-delayIntervalTask.voidaddFixedDelayTask(Runnable task, long delay) Add a Runnable task to be triggered with the given fixed delay.voidaddFixedDelayTask(Runnable task, Duration delay) Add a Runnable task to be triggered with the given fixed delay.voidaddFixedRateTask(IntervalTask task) Add a fixed-rateIntervalTask.voidaddFixedRateTask(Runnable task, long interval) Add aRunnabletask to be triggered at the given fixed-rate interval.voidaddFixedRateTask(Runnable task, Duration interval) Add aRunnabletask to be triggered at the given fixed-rate interval.voidaddTriggerTask(TriggerTask task) Add aTriggerTask.voidaddTriggerTask(Runnable task, Trigger trigger) Add a Runnable task to be triggered per the givenTrigger.voidCallsscheduleTasks()at bean construction time.voiddestroy()Get the cron tasks as an unmodifiable list ofCronTaskobjects.Get the fixed-delay tasks as an unmodifiable list ofIntervalTaskobjects.Get the fixed-rate tasks as an unmodifiable list ofIntervalTaskobjects.Return all locally registered tasks that have been scheduled by this registrar.Return theTaskSchedulerinstance for this registrar (may benull).Get the trigger tasks as an unmodifiable list ofTriggerTaskobjects.booleanhasTasks()Return whether thisScheduledTaskRegistrarhas any tasks registered.scheduleCronTask(CronTask task) Schedule the specified cron task, either right away if possible or on initialization of the scheduler.Schedule the specified fixed-delay task, either right away if possible or on initialization of the scheduler.Schedule the specified fixed-rate task, either right away if possible or on initialization of the scheduler.protected voidSchedule all registered tasks against the underlying task scheduler.Schedule the specified trigger task, either right away if possible or on initialization of the scheduler.voidsetCronTasks(Map<Runnable, String> cronTasks) Specify triggered tasks as a Map of Runnables (the tasks) and cron expressions.voidsetCronTasksList(List<CronTask> cronTasks) Specify triggered tasks as a list ofCronTaskobjects.voidsetFixedDelayTasks(Map<Runnable, Long> fixedDelayTasks) Specify triggered tasks as a Map of Runnables (the tasks) and fixed-delay values.voidsetFixedDelayTasksList(List<IntervalTask> fixedDelayTasks) Specify fixed-delay tasks as a list ofIntervalTaskobjects.voidsetFixedRateTasks(Map<Runnable, Long> fixedRateTasks) Specify triggered tasks as a Map of Runnables (the tasks) and fixed-rate values.voidsetFixedRateTasksList(List<IntervalTask> fixedRateTasks) Specify fixed-rate tasks as a list ofIntervalTaskobjects.voidsetScheduler(Object scheduler) Set theTaskSchedulerto register scheduled tasks with, or aScheduledExecutorServiceto be wrapped as aTaskScheduler.voidsetTaskScheduler(TaskScheduler taskScheduler) Set theTaskSchedulerto register scheduled tasks with.voidsetTriggerTasks(Map<Runnable, Trigger> triggerTasks) Specify triggered tasks as a Map of Runnables (the tasks) and Trigger objects (typically custom implementations of theTriggerinterface).voidsetTriggerTasksList(List<TriggerTask> triggerTasks) Specify triggered tasks as a list ofTriggerTaskobjects.
-
字段详细资料
-
CRON_DISABLED
A special cron expression value that indicates a disabled trigger: "-".This is primarily meant for use with
addCronTask(Runnable, String)when the value for the suppliedexpressionis retrieved from an external source — for example, from a property in theEnvironment.- 另请参阅:
-
-
构造器详细资料
-
ScheduledTaskRegistrar
public ScheduledTaskRegistrar()
-
-
方法详细资料
-
setTaskScheduler
Set theTaskSchedulerto register scheduled tasks with. -
setScheduler
Set theTaskSchedulerto register scheduled tasks with, or aScheduledExecutorServiceto be wrapped as aTaskScheduler. -
getScheduler
Return theTaskSchedulerinstance for this registrar (may benull). -
setTriggerTasks
Specify triggered tasks as a Map of Runnables (the tasks) and Trigger objects (typically custom implementations of theTriggerinterface). -
setTriggerTasksList
Specify triggered tasks as a list ofTriggerTaskobjects. Primarily used by<task:*>namespace parsing. -
getTriggerTaskList
Get the trigger tasks as an unmodifiable list ofTriggerTaskobjects.- 返回:
- the list of tasks (never
null)
-
setCronTasks
Specify triggered tasks as a Map of Runnables (the tasks) and cron expressions.- 另请参阅:
-
setCronTasksList
Specify triggered tasks as a list ofCronTaskobjects. Primarily used by<task:*>namespace parsing. -
getCronTaskList
Get the cron tasks as an unmodifiable list ofCronTaskobjects.- 返回:
- the list of tasks (never
null)
-
setFixedRateTasks
Specify triggered tasks as a Map of Runnables (the tasks) and fixed-rate values. -
setFixedRateTasksList
Specify fixed-rate tasks as a list ofIntervalTaskobjects. Primarily used by<task:*>namespace parsing. -
getFixedRateTaskList
Get the fixed-rate tasks as an unmodifiable list ofIntervalTaskobjects.- 返回:
- the list of tasks (never
null)
-
setFixedDelayTasks
Specify triggered tasks as a Map of Runnables (the tasks) and fixed-delay values. -
setFixedDelayTasksList
Specify fixed-delay tasks as a list ofIntervalTaskobjects. Primarily used by<task:*>namespace parsing. -
getFixedDelayTaskList
Get the fixed-delay tasks as an unmodifiable list ofIntervalTaskobjects.- 返回:
- the list of tasks (never
null)
-
addTriggerTask
Add a Runnable task to be triggered per the givenTrigger. -
addTriggerTask
Add aTriggerTask. -
addCronTask
Add aRunnabletask to be triggered per the given cronexpression.this method will not register the task if the
expressionis equal toCRON_DISABLED. -
addCronTask
Add aCronTask. -
addFixedRateTask
Add aRunnabletask to be triggered at the given fixed-rate interval. -
addFixedRateTask
Add aRunnabletask to be triggered at the given fixed-rate interval. -
addFixedRateTask
Add a fixed-rateIntervalTask. -
addFixedDelayTask
Add a Runnable task to be triggered with the given fixed delay. -
addFixedDelayTask
Add a Runnable task to be triggered with the given fixed delay. -
addFixedDelayTask
Add a fixed-delayIntervalTask. -
hasTasks
public boolean hasTasks()Return whether thisScheduledTaskRegistrarhas any tasks registered. -
afterPropertiesSet
public void afterPropertiesSet()CallsscheduleTasks()at bean construction time.- 指定者:
afterPropertiesSet在接口中InitializingBean
-
scheduleTasks
protected void scheduleTasks()Schedule all registered tasks against the underlying task scheduler. -
scheduleTriggerTask
Schedule the specified trigger task, either right away if possible or on initialization of the scheduler.- 返回:
- a handle to the scheduled task, allowing to cancel it
-
scheduleCronTask
Schedule the specified cron task, either right away if possible or on initialization of the scheduler.- 返回:
- a handle to the scheduled task, allowing to cancel it
(or
nullif processing a previously registered task)
-
scheduleFixedRateTask
Schedule the specified fixed-rate task, either right away if possible or on initialization of the scheduler.- 返回:
- a handle to the scheduled task, allowing to cancel it
(or
nullif processing a previously registered task)
-
scheduleFixedDelayTask
Schedule the specified fixed-delay task, either right away if possible or on initialization of the scheduler.- 返回:
- a handle to the scheduled task, allowing to cancel it
(or
nullif processing a previously registered task)
-
getScheduledTasks
Return all locally registered tasks that have been scheduled by this registrar. -
destroy
public void destroy()- 指定者:
destroy在接口中DisposableBean
-