Top Description Constructors Methods
org.springframework.scheduling.annotation

public Class AnnotationAsyncExecutionInterceptor

extends AsyncExecutionInterceptor
Class Inheritance
Imports
java.lang.reflect.Method, java.util.concurrent.Executor, org.springframework.aop.interceptor.AsyncExecutionInterceptor, .AsyncUncaughtExceptionHandler, org.springframework.core.annotation.AnnotatedElementUtils, org.springframework.lang.Nullable

Specialization of AsyncExecutionInterceptor that delegates method execution to an Executor based on the Async annotation.

Specifically designed to support use of the Async#value() executor qualifier mechanism.

Supports detecting qualifier metadata via @Async at the method or declaring class level. See getExecutorQualifier(Method) for details.

Authors
Chris Beams, Stephane Nicoll
Since
3.1.2
See Also
org.springframework.scheduling.annotation.Async, org.springframework.scheduling.annotation.AsyncAnnotationAdvisor

Constructor Summary

AccessConstructor and Description
public
AnnotationAsyncExecutionInterceptor(Executor
the executor to be used by default if no more specific executor has been qualified at the method level using Async#value(); a local executor for this interceptor will be built otherwise
defaultExecutor
)

Create a new AnnotationAsyncExecutionInterceptor with the given executor and a simple AsyncUncaughtExceptionHandler.

public
AnnotationAsyncExecutionInterceptor(Executor
the executor to be used by default if no more specific executor has been qualified at the method level using Async#value(); a local executor for this interceptor will be built otherwise
defaultExecutor
,
AsyncUncaughtExceptionHandler
the AsyncUncaughtExceptionHandler to use to handle exceptions thrown by asynchronous method executions with void return type
exceptionHandler
)

Create a new AnnotationAsyncExecutionInterceptor with the given executor.

Method Summary

Modifier and TypeMethod and Description
protected String

Returns:

the qualifier if specified, otherwise an empty string indicating that the default executor should be used
getExecutorQualifier
(Method
the method to inspect for executor qualifier metadata
method
)

Overrides org.springframework.aop.interceptor.AsyncExecutionInterceptor.getExecutorQualifier.

Return the qualifier or bean name of the executor to be used when executing the given method, specified via Async#value at the method or declaring class level.

Inherited from org.springframework.aop.interceptor.AsyncExecutionInterceptor:
getDefaultExecutorgetOrderinvoke

Constructor Detail

AnnotationAsyncExecutionInterceptorback to summary
public AnnotationAsyncExecutionInterceptor(Executor defaultExecutor)

Create a new AnnotationAsyncExecutionInterceptor with the given executor and a simple AsyncUncaughtExceptionHandler.

Parameters
defaultExecutor:Executor

the executor to be used by default if no more specific executor has been qualified at the method level using Async#value(); a local executor for this interceptor will be built otherwise

AnnotationAsyncExecutionInterceptorback to summary
public AnnotationAsyncExecutionInterceptor(Executor defaultExecutor, AsyncUncaughtExceptionHandler exceptionHandler)

Create a new AnnotationAsyncExecutionInterceptor with the given executor.

Parameters
defaultExecutor:Executor

the executor to be used by default if no more specific executor has been qualified at the method level using Async#value(); a local executor for this interceptor will be built otherwise

exceptionHandler:AsyncUncaughtExceptionHandler

the AsyncUncaughtExceptionHandler to use to handle exceptions thrown by asynchronous method executions with void return type

Method Detail

getExecutorQualifierback to summary
protected String getExecutorQualifier(Method method)

Overrides org.springframework.aop.interceptor.AsyncExecutionInterceptor.getExecutorQualifier.

Return the qualifier or bean name of the executor to be used when executing the given method, specified via Async#value at the method or declaring class level. If @Async is specified at both the method and class level, the method's value takes precedence (even if empty string, indicating that the default executor should be used preferentially).

Parameters
method:Method

the method to inspect for executor qualifier metadata

Returns:String

the qualifier if specified, otherwise an empty string indicating that the default executor should be used

Annotations
@Override
@Nullable
See Also
determineAsyncExecutor(Method)