Class AnnotationAsyncExecutionInterceptor
java.lang.Object
org.springframework.aop.interceptor.AsyncExecutionAspectSupport
org.springframework.aop.interceptor.AsyncExecutionInterceptor
org.springframework.scheduling.annotation.AnnotationAsyncExecutionInterceptor
- All Implemented Interfaces:
Advice, Interceptor, MethodInterceptor, Aware, BeanFactoryAware, Ordered
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.
- Since:
- 3.1.2
- Author:
- Chris Beams, Stephane Nicoll
- See Also:
-
Field Summary
Fields inherited from class AsyncExecutionAspectSupport
DEFAULT_TASK_EXECUTOR_BEAN_NAME, loggerFields inherited from interface Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionAnnotationAsyncExecutionInterceptor(@Nullable Executor defaultExecutor) Create a newAnnotationAsyncExecutionInterceptorwith the given executor and a simpleAsyncUncaughtExceptionHandler.AnnotationAsyncExecutionInterceptor(@Nullable Executor defaultExecutor, AsyncUncaughtExceptionHandler exceptionHandler) Create a newAnnotationAsyncExecutionInterceptorwith the given executor. -
Method Summary
Modifier and TypeMethodDescriptiongetExecutorQualifier(Method method) Return the qualifier or bean name of the executor to be used when executing the given method, specified viaAsync.value()at the method or declaring class level.Methods inherited from class AsyncExecutionInterceptor
getDefaultExecutor, getOrder, invokeMethods inherited from class AsyncExecutionAspectSupport
configure, determineAsyncExecutor, doSubmit, findQualifiedExecutor, handleError, setBeanFactory, setExceptionHandler, setExecutor
-
Constructor Details
-
AnnotationAsyncExecutionInterceptor
Create a newAnnotationAsyncExecutionInterceptorwith the given executor and a simpleAsyncUncaughtExceptionHandler.- Parameters:
defaultExecutor- the executor to be used by default if no more specific executor has been qualified at the method level usingAsync.value(); a local executor for this interceptor will be built otherwise
-
AnnotationAsyncExecutionInterceptor
public AnnotationAsyncExecutionInterceptor(@Nullable Executor defaultExecutor, AsyncUncaughtExceptionHandler exceptionHandler) Create a newAnnotationAsyncExecutionInterceptorwith the given executor.- Parameters:
defaultExecutor- the executor to be used by default if no more specific executor has been qualified at the method level usingAsync.value(); a local executor for this interceptor will be built otherwiseexceptionHandler- theAsyncUncaughtExceptionHandlerto use to handle exceptions thrown by asynchronous method executions withvoidreturn type
-
-
Method Details
-
getExecutorQualifier
Return the qualifier or bean name of the executor to be used when executing the given method, specified viaAsync.value()at the method or declaring class level. If@Asyncis specified at both the method and class level, the method'svaluetakes precedence (even if empty string, indicating that the default executor should be used preferentially).- Overrides:
getExecutorQualifierin classAsyncExecutionInterceptor- Parameters:
method- the method to inspect for executor qualifier metadata- Returns:
- the qualifier if specified, otherwise an empty string indicating that the default executor should be used
- See Also:
-