org.springframework.scheduling.annotation
Class AsyncAnnotationAdvisor

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

public class AsyncAnnotationAdvisor
extends AbstractPointcutAdvisor

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 javax.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:
PersistenceExceptionTranslationAdvisor, Repository, DataAccessException, PersistenceExceptionTranslator, Serialized Form

Field Summary
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
AsyncAnnotationAdvisor()
          Create a new ConcurrencyAnnotationBeanPostProcessor for bean-style configuration.
AsyncAnnotationAdvisor(Executor executor)
          Create a new ConcurrencyAnnotationBeanPostProcessor for the given task executor.
 
Method Summary
protected  Advice buildAdvice(Executor executor)
           
protected  Pointcut buildPointcut(Set<Class<? extends Annotation>> asyncAnnotationTypes)
          Calculate a pointcut for the given target class, if any.
 Advice getAdvice()
          Return the advice part of this aspect.
 Pointcut getPointcut()
          Get the Pointcut that drives this advisor.
 void setAsyncAnnotationType(Class<? extends Annotation> asyncAnnotationType)
          Set the 'async' annotation type.
 void setTaskExecutor(Executor executor)
          Specify the task executor to use for asynchronous methods.
 
Methods inherited from class org.springframework.aop.support.AbstractPointcutAdvisor
equals, getOrder, hashCode, isPerInstance, setOrder
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncAnnotationAdvisor

public AsyncAnnotationAdvisor()
Create a new ConcurrencyAnnotationBeanPostProcessor for bean-style configuration.


AsyncAnnotationAdvisor

public AsyncAnnotationAdvisor(Executor executor)
Create a new ConcurrencyAnnotationBeanPostProcessor for the given task executor.

Parameters:
executor - the task executor to use for asynchronous methods
Method Detail

setTaskExecutor

public void setTaskExecutor(Executor executor)
Specify the task executor to use for asynchronous methods.


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 javax.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

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.

Returns:
the advice that should apply if the pointcut matches
See Also:
MethodInterceptor, BeforeAdvice, ThrowsAdvice, AfterReturningAdvice

getPointcut

public Pointcut getPointcut()
Description copied from interface: PointcutAdvisor
Get the Pointcut that drives this advisor.


buildAdvice

protected Advice buildAdvice(Executor executor)

buildPointcut

protected Pointcut buildPointcut(Set<Class<? extends Annotation>> asyncAnnotationTypes)
Calculate a pointcut for the given target class, if any.

Parameters:
targetClass - the class to introspect
Returns:
the applicable Pointcut object, or null if none