public class ScheduledAnnotationBeanPostProcessor extends Object implements ScheduledTaskHolder, MergedBeanDefinitionPostProcessor, DestructionAwareBeanPostProcessor, Ordered, EmbeddedValueResolverAware, BeanNameAware, BeanFactoryAware, ApplicationContextAware, SmartInitializingSingleton, ApplicationListener<ContextRefreshedEvent>, DisposableBean
Scheduled
 to be invoked by a TaskScheduler according
 to the "fixedRate", "fixedDelay", or "cron" expression provided via the annotation.
 This post-processor is automatically registered by Spring's
 <task:annotation-driven> XML element, and also by the
 @EnableScheduling annotation.
 
Autodetects any SchedulingConfigurer instances in the container,
 allowing for customization of the scheduler to be used or for fine-grained
 control over task registration (e.g. registration of Trigger tasks.
 See the @EnableScheduling javadocs for complete usage details.
Scheduled, 
EnableScheduling, 
SchedulingConfigurer, 
TaskScheduler, 
ScheduledTaskRegistrar, 
AsyncAnnotationBeanPostProcessor| Modifier and Type | Field and Description | 
|---|---|
| static String | DEFAULT_TASK_SCHEDULER_BEAN_NAMEThe default name of the  TaskSchedulerbean to pick up: "taskScheduler". | 
| protected Log | logger | 
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE| Constructor and Description | 
|---|
| ScheduledAnnotationBeanPostProcessor()Create a default  ScheduledAnnotationBeanPostProcessor. | 
| ScheduledAnnotationBeanPostProcessor(ScheduledTaskRegistrar registrar)Create a  ScheduledAnnotationBeanPostProcessordelegating to the
 specifiedScheduledTaskRegistrar. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | afterSingletonsInstantiated()Invoked right at the end of the singleton pre-instantiation phase,
 with a guarantee that all regular singleton beans have been created
 already. | 
| protected Runnable | createRunnable(Object target,
              Method method)Create a  Runnablefor the given bean instance,
 calling the specified scheduled method. | 
| void | destroy()Invoked by the containing  BeanFactoryon destruction of a bean. | 
| int | getOrder()Get the order value of this object. | 
| Set<ScheduledTask> | getScheduledTasks()Return all currently scheduled tasks, from  Scheduledmethods
 as well as from programmaticSchedulingConfigurerinteraction. | 
| void | onApplicationEvent(ContextRefreshedEvent event)Handle an application event. | 
| Object | postProcessAfterInitialization(Object bean,
                              String beanName)Apply this  BeanPostProcessorto the given new bean instance after any bean
 initialization callbacks (like InitializingBean'safterPropertiesSetor a custom init-method). | 
| void | postProcessBeforeDestruction(Object bean,
                            String beanName)Apply this BeanPostProcessor to the given bean instance before its
 destruction, e.g. | 
| Object | postProcessBeforeInitialization(Object bean,
                               String beanName)Apply this  BeanPostProcessorto the given new bean instance before any bean
 initialization callbacks (like InitializingBean'safterPropertiesSetor a custom init-method). | 
| void | postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition,
                               Class<?> beanType,
                               String beanName)Post-process the given merged bean definition for the specified bean. | 
| protected void | processScheduled(Scheduled scheduled,
                Method method,
                Object bean)Process the given  @Scheduledmethod declaration on the given bean. | 
| boolean | requiresDestruction(Object bean)Determine whether the given bean instance requires destruction by this
 post-processor. | 
| void | setApplicationContext(ApplicationContext applicationContext)Setting an  ApplicationContextis optional: If set, registered
 tasks will be activated in theContextRefreshedEventphase;
 if not set, it will happen atafterSingletonsInstantiated()time. | 
| void | setBeanFactory(BeanFactory beanFactory)Making a  BeanFactoryavailable is optional; if not set,SchedulingConfigurerbeans won't get autodetected and
 aschedulerhas to be explicitly configured. | 
| void | setBeanName(String beanName)Set the name of the bean in the bean factory that created this bean. | 
| void | setEmbeddedValueResolver(StringValueResolver resolver)Set the StringValueResolver to use for resolving embedded definition values. | 
| void | setScheduler(Object scheduler)Set the  TaskSchedulerthat will invoke
 the scheduled methods, or aScheduledExecutorServiceto be wrapped as a TaskScheduler. | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitresetBeanDefinitionforPayloadpublic static final String DEFAULT_TASK_SCHEDULER_BEAN_NAME
TaskScheduler bean to pick up: "taskScheduler".
 Note that the initial lookup happens by type; this is just the fallback in case of multiple scheduler beans found in the context.
protected final Log logger
public ScheduledAnnotationBeanPostProcessor()
ScheduledAnnotationBeanPostProcessor.public ScheduledAnnotationBeanPostProcessor(ScheduledTaskRegistrar registrar)
ScheduledAnnotationBeanPostProcessor delegating to the
 specified ScheduledTaskRegistrar.registrar - the ScheduledTaskRegistrar to register @Scheduled tasks onpublic int getOrder()
OrderedHigher values are interpreted as lower priority. As a consequence,
 the object with the lowest value has the highest priority (somewhat
 analogous to Servlet load-on-startup values).
 
Same order values will result in arbitrary sort positions for the affected objects.
getOrder in interface OrderedOrdered.HIGHEST_PRECEDENCE, 
Ordered.LOWEST_PRECEDENCEpublic void setScheduler(Object scheduler)
TaskScheduler that will invoke
 the scheduled methods, or a ScheduledExecutorService
 to be wrapped as a TaskScheduler.
 If not specified, default scheduler resolution will apply: searching for a
 unique TaskScheduler bean in the context, or for a TaskScheduler
 bean named "taskScheduler" otherwise; the same lookup will also be performed for
 a ScheduledExecutorService bean. If neither of the two is resolvable,
 a local single-threaded default scheduler will be created within the registrar.
DEFAULT_TASK_SCHEDULER_BEAN_NAMEpublic void setEmbeddedValueResolver(StringValueResolver resolver)
EmbeddedValueResolverAwaresetEmbeddedValueResolver in interface EmbeddedValueResolverAwarepublic void setBeanName(String beanName)
BeanNameAwareInvoked after population of normal bean properties but before an
 init callback such as InitializingBean.afterPropertiesSet()
 or a custom init-method.
setBeanName in interface BeanNameAwarebeanName - the name of the bean in the factory.
 Note that this name is the actual bean name used in the factory, which may
 differ from the originally specified name: in particular for inner bean
 names, the actual bean name might have been made unique through appending
 "#..." suffixes. Use the BeanFactoryUtils.originalBeanName(String)
 method to extract the original bean name (without suffix), if desired.public void setBeanFactory(BeanFactory beanFactory)
BeanFactory available is optional; if not set,
 SchedulingConfigurer beans won't get autodetected and
 a scheduler has to be explicitly configured.setBeanFactory in interface BeanFactoryAwarebeanFactory - owning BeanFactory (never null).
 The bean can immediately call methods on the factory.BeanInitializationExceptionpublic void setApplicationContext(ApplicationContext applicationContext)
ApplicationContext is optional: If set, registered
 tasks will be activated in the ContextRefreshedEvent phase;
 if not set, it will happen at afterSingletonsInstantiated() time.setApplicationContext in interface ApplicationContextAwareapplicationContext - the ApplicationContext object to be used by this objectBeanInitializationExceptionpublic void afterSingletonsInstantiated()
SmartInitializingSingletonListableBeanFactory.getBeansOfType(java.lang.Class<T>) calls within
 this method won't trigger accidental side effects during bootstrap.
 NOTE: This callback won't be triggered for singleton beans
 lazily initialized on demand after BeanFactory bootstrap,
 and not for any other bean scope either. Carefully use it for beans
 with the intended bootstrap semantics only.
afterSingletonsInstantiated in interface SmartInitializingSingletonpublic void onApplicationEvent(ContextRefreshedEvent event)
ApplicationListeneronApplicationEvent in interface ApplicationListener<ContextRefreshedEvent>event - the event to respond topublic void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName)
MergedBeanDefinitionPostProcessorpostProcessMergedBeanDefinition in interface MergedBeanDefinitionPostProcessorbeanDefinition - the merged bean definition for the beanbeanType - the actual type of the managed bean instancebeanName - the name of the beanAbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(org.springframework.beans.factory.support.RootBeanDefinition, java.lang.Class<?>, java.lang.String)public Object postProcessBeforeInitialization(Object bean, String beanName)
BeanPostProcessorBeanPostProcessor to the given new bean instance before any bean
 initialization callbacks (like InitializingBean's afterPropertiesSet
 or a custom init-method). The bean will already be populated with property values.
 The returned bean instance may be a wrapper around the original.
 The default implementation returns the given bean as-is.
postProcessBeforeInitialization in interface BeanPostProcessorbean - the new bean instancebeanName - the name of the beannull, no subsequent BeanPostProcessors will be invokedInitializingBean.afterPropertiesSet()public Object postProcessAfterInitialization(Object bean, String beanName)
BeanPostProcessorBeanPostProcessor to the given new bean instance after any bean
 initialization callbacks (like InitializingBean's afterPropertiesSet
 or a custom init-method). The bean will already be populated with property values.
 The returned bean instance may be a wrapper around the original.
 In case of a FactoryBean, this callback will be invoked for both the FactoryBean
 instance and the objects created by the FactoryBean (as of Spring 2.0). The
 post-processor can decide whether to apply to either the FactoryBean or created
 objects or both through corresponding bean instanceof FactoryBean checks.
 
This callback will also be invoked after a short-circuiting triggered by a
 InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation(java.lang.Class<?>, java.lang.String) method,
 in contrast to all other BeanPostProcessor callbacks.
 
The default implementation returns the given bean as-is.
postProcessAfterInitialization in interface BeanPostProcessorbean - the new bean instancebeanName - the name of the beannull, no subsequent BeanPostProcessors will be invokedInitializingBean.afterPropertiesSet(), 
FactoryBeanprotected void processScheduled(Scheduled scheduled, Method method, Object bean)
@Scheduled method declaration on the given bean.scheduled - the @Scheduled annotationmethod - the method that the annotation has been declared onbean - the target bean instancecreateRunnable(Object, Method)protected Runnable createRunnable(Object target, Method method)
Runnable for the given bean instance,
 calling the specified scheduled method.
 The default implementation creates a ScheduledMethodRunnable.
target - the target bean instancemethod - the scheduled method to callScheduledMethodRunnable.ScheduledMethodRunnable(Object, Method)public Set<ScheduledTask> getScheduledTasks()
Scheduled methods
 as well as from programmatic SchedulingConfigurer interaction.getScheduledTasks in interface ScheduledTaskHolderpublic void postProcessBeforeDestruction(Object bean, String beanName)
DestructionAwareBeanPostProcessorLike DisposableBean's destroy and a custom destroy method, this
 callback will only apply to beans which the container fully manages the
 lifecycle for. This is usually the case for singletons and scoped beans.
postProcessBeforeDestruction in interface DestructionAwareBeanPostProcessorbean - the bean instance to be destroyedbeanName - the name of the beanDisposableBean.destroy(), 
AbstractBeanDefinition.setDestroyMethodName(String)public boolean requiresDestruction(Object bean)
DestructionAwareBeanPostProcessorThe default implementation returns true. If a pre-5 implementation
 of DestructionAwareBeanPostProcessor does not provide a concrete
 implementation of this method, Spring silently assumes true as well.
requiresDestruction in interface DestructionAwareBeanPostProcessorbean - the bean instance to checktrue if DestructionAwareBeanPostProcessor.postProcessBeforeDestruction(java.lang.Object, java.lang.String) is supposed to
 be called for this bean instance eventually, or false if not neededpublic void destroy()
DisposableBeanBeanFactory on destruction of a bean.destroy in interface DisposableBean