public class ContextLifecycleScheduledTaskRegistrar extends ScheduledTaskRegistrar implements ApplicationContextAware, ApplicationListener<ContextRefreshedEvent>
ScheduledTaskRegistrar subclass that redirects the actual scheduling
of tasks to the ContextRefreshedEvent callback. Falls back to regular
ScheduledTaskRegistrar behavior when not running within an ApplicationContext.| Constructor and Description |
|---|
ContextLifecycleScheduledTaskRegistrar() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet()
If we're running within an ApplicationContext, don't schedule the tasks
right here; wait for this context's ContextRefreshedEvent instead.
|
void |
onApplicationEvent(ContextRefreshedEvent event)
Actually schedule the tasks at the right time of the context lifecycle,
if we're running within an ApplicationContext.
|
void |
setApplicationContext(ApplicationContext applicationContext)
Set the ApplicationContext that this object runs in.
|
addCronTask, addCronTask, addFixedDelayTask, addFixedDelayTask, addFixedRateTask, addFixedRateTask, addTriggerTask, addTriggerTask, destroy, getScheduler, hasTasks, scheduleTasks, setCronTasks, setCronTasksList, setFixedDelayTasks, setFixedDelayTasksList, setFixedRateTasks, setFixedRateTasksList, setScheduler, setTaskScheduler, setTriggerTasks, setTriggerTasksListpublic ContextLifecycleScheduledTaskRegistrar()
public void setApplicationContext(ApplicationContext applicationContext)
ApplicationContextAwareInvoked after population of normal bean properties but before an init callback such
as InitializingBean.afterPropertiesSet()
or a custom init-method. Invoked after ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader),
ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) and
MessageSourceAware, if applicable.
setApplicationContext in interface ApplicationContextAwareapplicationContext - the ApplicationContext object to be used by this objectBeanInitializationExceptionpublic void afterPropertiesSet()
afterPropertiesSet in interface InitializingBeanafterPropertiesSet in class ScheduledTaskRegistrarpublic void onApplicationEvent(ContextRefreshedEvent event)
onApplicationEvent in interface ApplicationListener<ContextRefreshedEvent>event - the event to respond to