public class AnnotationAsyncExecutionInterceptor extends AsyncExecutionInterceptor
AsyncExecutionInterceptor
that delegates method execution to
an Executor
based on the Async
annotation. Specifically designed to
support use of Async.value()
executor qualification mechanism introduced in
Spring 3.1.2. Supports detecting qualifier metadata via @Async
at the method or
declaring class level. See getExecutorQualifier(Method)
for details.Async
,
AsyncAnnotationAdvisor
DEFAULT_TASK_EXECUTOR_BEAN_NAME, logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
AnnotationAsyncExecutionInterceptor(Executor defaultExecutor)
Create a new
AnnotationAsyncExecutionInterceptor with the given executor
and a simple AsyncUncaughtExceptionHandler . |
AnnotationAsyncExecutionInterceptor(Executor defaultExecutor,
AsyncUncaughtExceptionHandler exceptionHandler)
Create a new
AnnotationAsyncExecutionInterceptor with the given executor. |
Modifier and Type | Method and Description |
---|---|
protected String |
getExecutorQualifier(Method method)
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. |
getDefaultExecutor, getOrder, invoke
determineAsyncExecutor, doSubmit, findQualifiedExecutor, handleError, setBeanFactory, setExceptionHandler, setExecutor
public AnnotationAsyncExecutionInterceptor(@Nullable Executor defaultExecutor)
AnnotationAsyncExecutionInterceptor
with the given executor
and a simple AsyncUncaughtExceptionHandler
.defaultExecutor
- the executor to be used by default if no more specific
executor has been qualified at the method level using Async.value()
;
as of 4.2.6, a local executor for this interceptor will be built otherwisepublic AnnotationAsyncExecutionInterceptor(@Nullable Executor defaultExecutor, AsyncUncaughtExceptionHandler exceptionHandler)
AnnotationAsyncExecutionInterceptor
with the given executor.defaultExecutor
- the executor to be used by default if no more specific
executor has been qualified at the method level using Async.value()
;
as of 4.2.6, a local executor for this interceptor will be built otherwiseexceptionHandler
- the AsyncUncaughtExceptionHandler
to use to
handle exceptions thrown by asynchronous method executions with void
return type@Nullable protected String getExecutorQualifier(Method method)
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).getExecutorQualifier
in class AsyncExecutionInterceptor
method
- the method to inspect for executor qualifier metadataAsyncExecutionAspectSupport.determineAsyncExecutor(Method)