Class AsyncAnnotationAdvisor

java.lang.Object
org.springframework.aop.support.AbstractPointcutAdvisor
org.springframework.scheduling.annotation.AsyncAnnotationAdvisor
All Implemented Interfaces:
Serializable, Advisor, PointcutAdvisor, Aware, BeanFactoryAware, Ordered

public class AsyncAnnotationAdvisor extends AbstractPointcutAdvisor implements BeanFactoryAware
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:
  • Constructor Details

  • Method Details

    • setAsyncAnnotationType

      public void setAsyncAnnotationType(Class<? extends Annotation> asyncAnnotationType)
      Set the 'async' annotation type.

      The default async annotation type is the Async annotation, as well as the EJB 3.1 jakarta.ejb.Asynchronous annotation (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
    • setBeanFactory

      public void setBeanFactory(BeanFactory beanFactory)
      Set the BeanFactory to be used when looking up executors by qualifier.
      Specified by:
      setBeanFactory in interface BeanFactoryAware
      Parameters:
      beanFactory - owning BeanFactory (never null). The bean can immediately call methods on the factory.
      See Also:
    • getAdvice

      public Advice getAdvice()
      Description copied from interface: Advisor
      Return the advice part of this aspect. An advice may be an interceptor, a before advice, a throws advice, etc.
      Specified by:
      getAdvice in interface Advisor
      Returns:
      the advice that should apply if the pointcut matches
      See Also:
    • getPointcut

      public Pointcut getPointcut()
      Description copied from interface: PointcutAdvisor
      Get the Pointcut that drives this advisor.
      Specified by:
      getPointcut in interface 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.
      Parameters:
      asyncAnnotationTypes - the async annotation types to introspect
      Returns:
      the applicable Pointcut object, or null if none