类 AsyncAnnotationAdvisor
- java.lang.Object
- org.springframework.aop.support.AbstractPointcutAdvisor
- org.springframework.scheduling.annotation.AsyncAnnotationAdvisor
- 所有已实现的接口:
Serializable,Advisor,PointcutAdvisor,Aware,BeanFactoryAware,Ordered
public class AsyncAnnotationAdvisor extends AbstractPointcutAdvisor implements BeanFactoryAware
Advisor that activates asynchronous method execution through theAsyncannotation. 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
javax.ejb.Asynchronousannotation as well, treating it exactly like Spring's ownAsync. Furthermore, a custom async annotation type may get specified through the"asyncAnnotationType"property.- 从以下版本开始:
- 3.0
- 作者:
- Juergen Hoeller
- 另请参阅:
Async,AnnotationAsyncExecutionInterceptor, 序列化表格
字段概要
从接口继承的字段 org.springframework.aop.Advisor
EMPTY_ADVICE
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 AsyncAnnotationAdvisor()Create 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.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected 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.AdvicegetAdvice()Return the advice part of this aspect.PointcutgetPointcut()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.从类继承的方法 org.springframework.aop.support.AbstractPointcutAdvisor
equals, getOrder, hashCode, isPerInstance, setOrder
构造器详细资料
AsyncAnnotationAdvisor
public AsyncAnnotationAdvisor()
Create a newAsyncAnnotationAdvisorfor bean-style configuration.
AsyncAnnotationAdvisor
public AsyncAnnotationAdvisor(@Nullable Executor executor, @Nullable AsyncUncaughtExceptionHandler exceptionHandler)
Create a newAsyncAnnotationAdvisorfor the given task executor.- 参数:
executor- the task executor to use for asynchronous methods (can benullto trigger default executor resolution)exceptionHandler- theAsyncUncaughtExceptionHandlerto use to handle unexpected exception thrown by asynchronous method executions- 另请参阅:
AsyncExecutionInterceptor.getDefaultExecutor(BeanFactory)
AsyncAnnotationAdvisor
public AsyncAnnotationAdvisor(@Nullable Supplier<Executor> executor, @Nullable Supplier<AsyncUncaughtExceptionHandler> exceptionHandler)
Create a newAsyncAnnotationAdvisorfor the given task executor.- 参数:
executor- the task executor to use for asynchronous methods (can benullto trigger default executor resolution)exceptionHandler- theAsyncUncaughtExceptionHandlerto use to handle unexpected exception thrown by asynchronous method executions- 从以下版本开始:
- 5.1
- 另请参阅:
AsyncExecutionInterceptor.getDefaultExecutor(BeanFactory)
方法详细资料
setAsyncAnnotationType
public void setAsyncAnnotationType(Class<? extends Annotation> asyncAnnotationType)
Set the 'async' annotation type.The default async annotation type is the
Asyncannotation, as well as the EJB 3.1javax.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.
- 参数:
asyncAnnotationType- the desired annotation type
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)
Set theBeanFactoryto be used when looking up executors by qualifier.- 指定者:
setBeanFactory在接口中BeanFactoryAware- 参数:
beanFactory- owning BeanFactory (nevernull). The bean can immediately call methods on the factory.- 另请参阅:
BeanInitializationException
getAdvice
public Advice getAdvice()
从接口复制的说明:AdvisorReturn the advice part of this aspect. An advice may be an interceptor, a before advice, a throws advice, etc.- 指定者:
getAdvice在接口中Advisor- 返回:
- the advice that should apply if the pointcut matches
- 另请参阅:
MethodInterceptor,BeforeAdvice,ThrowsAdvice,AfterReturningAdvice
getPointcut
public Pointcut getPointcut()
从接口复制的说明:PointcutAdvisorGet the Pointcut that drives this advisor.- 指定者:
getPointcut在接口中PointcutAdvisor
buildAdvice
protected Advice buildAdvice(@Nullable Supplier<Executor> executor, @Nullable Supplier<AsyncUncaughtExceptionHandler> exceptionHandler)
buildPointcut
protected Pointcut buildPointcut(Set<Class<? extends Annotation>> asyncAnnotationTypes)
Calculate a pointcut for the given async annotation types, if any.- 参数:
asyncAnnotationTypes- the async annotation types to introspect- 返回:
- the applicable Pointcut object, or
nullif none