spring-aop

org.springframework.aop.interceptor
Class AsyncExecutionAspectSupport

java.lang.Object
  extended by org.springframework.aop.interceptor.AsyncExecutionAspectSupport
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware
Direct Known Subclasses:
AsyncExecutionInterceptor

public abstract class AsyncExecutionAspectSupport
extends java.lang.Object
implements org.springframework.beans.factory.BeanFactoryAware

Base class for asynchronous method execution aspects, such as org.springframework.scheduling.annotation.AnnotationAsyncExecutionInterceptor or org.springframework.scheduling.aspectj.AnnotationAsyncExecutionAspect.

Provides support for executor qualification on a method-by-method basis. AsyncExecutionAspectSupport objects must be constructed with a default Executor, but each individual method may further qualify a specific Executor bean to be used when executing it, e.g. through an annotation attribute.

Since:
3.2
Author:
Chris Beams

Constructor Summary
AsyncExecutionAspectSupport(java.util.concurrent.Executor defaultExecutor)
          Create a new AsyncExecutionAspectSupport, using the provided default executor unless individual async methods indicate via qualifier that a more specific executor should be used.
 
Method Summary
protected  org.springframework.core.task.AsyncTaskExecutor determineAsyncExecutor(java.lang.reflect.Method method)
          Determine the specific executor to use when executing the given method.
protected abstract  java.lang.String getExecutorQualifier(java.lang.reflect.Method method)
          Return the qualifier or bean name of the executor to be used when executing the given async method, typically specified in the form of an annotation attribute.
 void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
          Set the BeanFactory to be used when looking up executors by qualifier.
 void setExecutor(java.util.concurrent.Executor defaultExecutor)
          Supply the executor to be used when executing async methods.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncExecutionAspectSupport

public AsyncExecutionAspectSupport(java.util.concurrent.Executor defaultExecutor)
Create a new AsyncExecutionAspectSupport, using the provided default executor unless individual async methods indicate via qualifier that a more specific executor should be used.

Parameters:
defaultExecutor - the executor to use when executing asynchronous methods
Method Detail

setExecutor

public void setExecutor(java.util.concurrent.Executor defaultExecutor)
Supply the executor to be used when executing async methods.

Parameters:
defaultExecutor - the Executor (typically a Spring AsyncTaskExecutor or ExecutorService) to delegate to unless a more specific executor has been requested via a qualifier on the async method, in which case the executor will be looked up at invocation time against the enclosing bean factory.
See Also:
getExecutorQualifier(java.lang.reflect.Method), setBeanFactory(BeanFactory)

setBeanFactory

public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
                    throws org.springframework.beans.BeansException
Set the BeanFactory to be used when looking up executors by qualifier.

Specified by:
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
Throws:
org.springframework.beans.BeansException

getExecutorQualifier

protected abstract java.lang.String getExecutorQualifier(java.lang.reflect.Method method)
Return the qualifier or bean name of the executor to be used when executing the given async method, typically specified in the form of an annotation attribute. Returning an empty string or null indicates that no specific executor has been specified and that the default executor should be used.

Parameters:
method - the method to inspect for executor qualifier metadata
Returns:
the qualifier if specified, otherwise empty string or null
See Also:
determineAsyncExecutor(Method)

determineAsyncExecutor

protected org.springframework.core.task.AsyncTaskExecutor determineAsyncExecutor(java.lang.reflect.Method method)
Determine the specific executor to use when executing the given method.


spring-aop