Class AsyncAnnotationAdvisor
java.lang.Object
org.springframework.aop.support.AbstractPointcutAdvisor
org.springframework.scheduling.annotation.AsyncAnnotationAdvisor
- All Implemented Interfaces:
- Serializable,- Advisor,- PointcutAdvisor,- Aware,- BeanFactoryAware,- Ordered
Advisor that activates asynchronous method execution through the 
Async
 annotation. This annotation can be used at the method and type level in
 implementation classes as well as in service interfaces.
 This advisor detects the EJB 3.1 jakarta.ejb.Asynchronous
 annotation as well, treating it exactly like Spring's own Async.
 Furthermore, a custom async annotation type may get specified through the
 "asyncAnnotationType" property.
- Since:
- 3.0
- Author:
- Juergen Hoeller
- See Also:
- 
Field SummaryFields inherited from interface org.springframework.aop.AdvisorEMPTY_ADVICEFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a newAsyncAnnotationAdvisorfor bean-style configuration.AsyncAnnotationAdvisor(Executor executor, AsyncUncaughtExceptionHandler exceptionHandler) Create a newAsyncAnnotationAdvisorfor the given task executor.AsyncAnnotationAdvisor(Supplier<Executor> executor, Supplier<AsyncUncaughtExceptionHandler> exceptionHandler) Create a newAsyncAnnotationAdvisorfor the given task executor.
- 
Method SummaryModifier and TypeMethodDescriptionprotected AdvicebuildAdvice(Supplier<Executor> executor, Supplier<AsyncUncaughtExceptionHandler> exceptionHandler) protected PointcutbuildPointcut(Set<Class<? extends Annotation>> asyncAnnotationTypes) Calculate a pointcut for the given async annotation types, if any.Return the advice part of this aspect.Get the Pointcut that drives this advisor.voidsetAsyncAnnotationType(Class<? extends Annotation> asyncAnnotationType) Set the 'async' annotation type.voidsetBeanFactory(BeanFactory beanFactory) Set theBeanFactoryto be used when looking up executors by qualifier.Methods inherited from class org.springframework.aop.support.AbstractPointcutAdvisorequals, getOrder, hashCode, setOrderMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.aop.AdvisorisPerInstance
- 
Constructor Details- 
AsyncAnnotationAdvisorpublic AsyncAnnotationAdvisor()Create a newAsyncAnnotationAdvisorfor bean-style configuration.
- 
AsyncAnnotationAdvisorpublic AsyncAnnotationAdvisor(@Nullable Executor executor, @Nullable AsyncUncaughtExceptionHandler exceptionHandler) Create a newAsyncAnnotationAdvisorfor the given task executor.- Parameters:
- executor- the task executor to use for asynchronous methods (can be- nullto trigger default executor resolution)
- exceptionHandler- the- AsyncUncaughtExceptionHandlerto use to handle unexpected exception thrown by asynchronous method executions
- See Also:
 
- 
AsyncAnnotationAdvisorpublic AsyncAnnotationAdvisor(@Nullable Supplier<Executor> executor, @Nullable Supplier<AsyncUncaughtExceptionHandler> exceptionHandler) Create a newAsyncAnnotationAdvisorfor the given task executor.- Parameters:
- executor- the task executor to use for asynchronous methods (can be- nullto trigger default executor resolution)
- exceptionHandler- the- AsyncUncaughtExceptionHandlerto use to handle unexpected exception thrown by asynchronous method executions
- Since:
- 5.1
- See Also:
 
 
- 
- 
Method Details- 
setAsyncAnnotationTypeSet the 'async' annotation type.The default async annotation type is the Asyncannotation, as well as the EJB 3.1jakarta.ejb.Asynchronousannotation (if present).This setter property exists so that developers can provide their own (non-Spring-specific) annotation type to indicate that a method is to be executed asynchronously. - Parameters:
- asyncAnnotationType- the desired annotation type
 
- 
setBeanFactorySet theBeanFactoryto be used when looking up executors by qualifier.- Specified by:
- setBeanFactoryin interface- BeanFactoryAware
- Parameters:
- beanFactory- owning BeanFactory (never- null). The bean can immediately call methods on the factory.
- See Also:
 
- 
getAdviceDescription copied from interface:AdvisorReturn the advice part of this aspect. An advice may be an interceptor, a before advice, a throws advice, etc.
- 
getPointcutDescription copied from interface:PointcutAdvisorGet the Pointcut that drives this advisor.- Specified by:
- getPointcutin interface- PointcutAdvisor
 
- 
buildAdvice
- 
buildPointcutCalculate a pointcut for the given async annotation types, if any.- Parameters:
- asyncAnnotationTypes- the async annotation types to introspect
- Returns:
- the applicable Pointcut object, or nullif none
 
 
-