org.springframework.scheduling.config
Class ScheduledTaskRegistrar

java.lang.Object
  extended by org.springframework.scheduling.config.ScheduledTaskRegistrar
All Implemented Interfaces:
DisposableBean, InitializingBean

public class ScheduledTaskRegistrar
extends java.lang.Object
implements InitializingBean, DisposableBean

Helper bean for registering tasks with a TaskScheduler, typically using cron expressions.

Since:
3.0
Author:
Juergen Hoeller

Field Summary
private  java.util.Map<java.lang.Runnable,java.lang.String> cronTasks
           
private  java.util.Map<java.lang.Runnable,java.lang.Long> fixedDelayTasks
           
private  java.util.Map<java.lang.Runnable,java.lang.Long> fixedRateTasks
           
private  java.util.concurrent.ScheduledExecutorService localExecutor
           
private  java.util.Set<java.util.concurrent.ScheduledFuture> scheduledFutures
           
private  TaskScheduler taskScheduler
           
private  java.util.Map<java.lang.Runnable,Trigger> triggerTasks
           
 
Constructor Summary
ScheduledTaskRegistrar()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
 void destroy()
          Invoked by a BeanFactory on destruction of a singleton.
 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 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 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 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).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

taskScheduler

private TaskScheduler taskScheduler

localExecutor

private java.util.concurrent.ScheduledExecutorService localExecutor

triggerTasks

private java.util.Map<java.lang.Runnable,Trigger> triggerTasks

cronTasks

private java.util.Map<java.lang.Runnable,java.lang.String> cronTasks

fixedRateTasks

private java.util.Map<java.lang.Runnable,java.lang.Long> fixedRateTasks

fixedDelayTasks

private java.util.Map<java.lang.Runnable,java.lang.Long> fixedDelayTasks

scheduledFutures

private final java.util.Set<java.util.concurrent.ScheduledFuture> scheduledFutures
Constructor Detail

ScheduledTaskRegistrar

public ScheduledTaskRegistrar()
Method Detail

setTaskScheduler

public void setTaskScheduler(TaskScheduler taskScheduler)
Set the TaskScheduler to register scheduled tasks with.


setScheduler

public void setScheduler(java.lang.Object scheduler)
Set the TaskScheduler to register scheduled tasks with, or a ScheduledExecutorService to be wrapped as a TaskScheduler.


setTriggerTasks

public 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).


setCronTasks

public 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.

See Also:
CronTrigger

setFixedRateTasks

public 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.

See Also:
TaskScheduler.scheduleAtFixedRate(Runnable, long)

setFixedDelayTasks

public 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.

See Also:
TaskScheduler.scheduleWithFixedDelay(Runnable, long)

afterPropertiesSet

public void afterPropertiesSet()
Description copied from interface: InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Specified by:
afterPropertiesSet in interface InitializingBean

destroy

public void destroy()
Description copied from interface: DisposableBean
Invoked by a BeanFactory on destruction of a singleton.

Specified by:
destroy in interface DisposableBean