ContextLifecycleScheduledTaskRegistrar (Spring Framework 3.2.1.RELEASE API)
Date: 2013-01-24

org.springframework.scheduling.config

## Class ContextLifecycleScheduledTaskRegistrar

- java.lang.Object
- - org.springframework.scheduling.config.ScheduledTaskRegistrar
  - - org.springframework.scheduling.config.ContextLifecycleScheduledTaskRegistrar

- All Implemented Interfaces:
    EventListener, Aware, DisposableBean, InitializingBean, ApplicationContextAware, ApplicationListener<ContextRefreshedEvent>

      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.
  Since:
    3.2.1
  Author:
    Juergen Hoeller

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ContextLifecycleScheduledTaskRegistrar()`

  - ### Method Summary

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

    - ### Methods inherited from class org.springframework.scheduling.config.ScheduledTaskRegistrar

      `addCronTask, addCronTask, addFixedDelayTask, addFixedDelayTask, addFixedRateTask, addFixedRateTask, addTriggerTask, addTriggerTask, destroy, getScheduler, hasTasks, scheduleTasks, setCronTasks, setCronTasksList, setFixedDelayTasks, setFixedDelayTasksList, setFixedRateTasks, setFixedRateTasksList, setScheduler, setTaskScheduler, setTriggerTasks, setTriggerTasksList`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ContextLifecycleScheduledTaskRegistrar

          public ContextLifecycleScheduledTaskRegistrar()

  - ### Method Detail

    - #### setApplicationContext

          public void setApplicationContext(ApplicationContext applicationContext)

      Description copied from interface: `ApplicationContextAware`
      Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.

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

      Specified by:
        `setApplicationContext` in interface `ApplicationContextAware`
      Parameters:
        `applicationContext` - the ApplicationContext object to be used by this object
      See Also:
        `BeanInitializationException`

    - #### afterPropertiesSet

          public void afterPropertiesSet()

      If we're running within an ApplicationContext, don't schedule the tasks right here; wait for this context's ContextRefreshedEvent instead.
      Specified by:
        `afterPropertiesSet` in interface `InitializingBean`
      Overrides:
        `afterPropertiesSet` in class `ScheduledTaskRegistrar`

    - #### onApplicationEvent

          public void onApplicationEvent(ContextRefreshedEvent event)

      Actually schedule the tasks at the right time of the context lifecycle, if we're running within an ApplicationContext.
      Specified by:
        `onApplicationEvent` in interface `ApplicationListener<ContextRefreshedEvent>`
      Parameters:
        `event` - the event to respond to