spring-context

org.springframework.scheduling.annotation
Class ScheduledAnnotationBeanPostProcessor

java.lang.Object
  extended by org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor
All Implemented Interfaces:
java.util.EventListener, org.springframework.beans.factory.Aware, org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.beans.factory.DisposableBean, ApplicationContextAware, ApplicationListener<ContextRefreshedEvent>, EmbeddedValueResolverAware, org.springframework.core.Ordered

public class ScheduledAnnotationBeanPostProcessor
extends java.lang.Object
implements org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.core.Ordered, EmbeddedValueResolverAware, ApplicationContextAware, ApplicationListener<ContextRefreshedEvent>, org.springframework.beans.factory.DisposableBean

Bean post-processor that registers methods annotated with @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.

Auto-detects 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 @EnableScheduling Javadoc for complete usage details.

Since:
3.0
Author:
Mark Fisher, Juergen Hoeller, Chris Beams
See Also:
Scheduled, EnableScheduling, SchedulingConfigurer, TaskScheduler, ScheduledTaskRegistrar

Field Summary
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
ScheduledAnnotationBeanPostProcessor()
           
 
Method Summary
 void destroy()
           
 int getOrder()
           
 void onApplicationEvent(ContextRefreshedEvent event)
          Handle an application event.
 java.lang.Object postProcessAfterInitialization(java.lang.Object bean, java.lang.String beanName)
           
 java.lang.Object postProcessBeforeInitialization(java.lang.Object bean, java.lang.String beanName)
           
 void setApplicationContext(ApplicationContext applicationContext)
          Set the ApplicationContext that this object runs in.
 void setEmbeddedValueResolver(org.springframework.util.StringValueResolver resolver)
          Set the StringValueResolver to use for resolving embedded definition values.
 void setScheduler(java.lang.Object scheduler)
          Set the TaskScheduler that will invoke the scheduled methods, or a ScheduledExecutorService to be wrapped as a TaskScheduler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScheduledAnnotationBeanPostProcessor

public ScheduledAnnotationBeanPostProcessor()
Method Detail

setScheduler

public void setScheduler(java.lang.Object scheduler)
Set the TaskScheduler that will invoke the scheduled methods, or a ScheduledExecutorService to be wrapped as a TaskScheduler.


setEmbeddedValueResolver

public void setEmbeddedValueResolver(org.springframework.util.StringValueResolver resolver)
Description copied from interface: EmbeddedValueResolverAware
Set the StringValueResolver to use for resolving embedded definition values.

Specified by:
setEmbeddedValueResolver in interface EmbeddedValueResolverAware

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

getOrder

public int getOrder()
Specified by:
getOrder in interface org.springframework.core.Ordered

postProcessBeforeInitialization

public java.lang.Object postProcessBeforeInitialization(java.lang.Object bean,
                                                        java.lang.String beanName)
Specified by:
postProcessBeforeInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor

postProcessAfterInitialization

public java.lang.Object postProcessAfterInitialization(java.lang.Object bean,
                                                       java.lang.String beanName)
Specified by:
postProcessAfterInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor

onApplicationEvent

public void onApplicationEvent(ContextRefreshedEvent event)
Description copied from interface: ApplicationListener
Handle an application event.

Specified by:
onApplicationEvent in interface ApplicationListener<ContextRefreshedEvent>
Parameters:
event - the event to respond to

destroy

public void destroy()
             throws java.lang.Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
java.lang.Exception

spring-context