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.
| Modifier and Type | Field and Description |
|---|---|
| private BeanFactory | |
| public static final String | DEFAULT_TASK_EXECUTOR_BEAN_NAME
The default name of the |
| private SingletonSupplier | |
| private StringValueResolver | |
| private SingletonSupplier | |
| private final Map | |
| protected final Log |
| Access | Constructor and Description |
|---|---|
| public | AsyncExecutionAspectSupport(Executor
the defaultExecutor)Executor (typically a Spring AsyncTaskExecutor
or java.) 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 factoryCreate a new instance with a default |
| public | AsyncExecutionAspectSupport(Executor
the defaultExecutor, AsyncUncaughtExceptionHandler Executor (typically a Spring AsyncTaskExecutor
or java.) 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 factorythe exceptionHandler)AsyncUncaughtExceptionHandler to useCreate a new |
| Modifier and Type | Method and Description |
|---|---|
| public void | configure(Supplier<Executor> defaultExecutor, Supplier<AsyncUncaughtExceptionHandler> exceptionHandler)
Configure this aspect with the given executor and exception handler suppliers, applying the corresponding default if a supplier is not resolvable. |
| protected AsyncTaskExecutor | Returns: the executor to use (ornull, but just if no default executor is available)Determine the specific executor to use when executing the given method. |
| protected Object | Returns: the execution result (potentially a correspondingFuture handle)the task to execute task, AsyncTaskExecutor the chosen executor executor, Class<?> the declared return type (potentially a returnType)Future variant)Delegate for actually executing the given task with the chosen executor. |
| protected Executor | Returns: the target executor, ornull if none availablethe qualifier to resolve qualifier)Retrieve a target executor for the given qualifier. |
| protected Executor | Returns: the default executor, ornull if none availablethe BeanFactory to use for a default executor lookup beanFactory)Retrieve or build a default executor for this advice instance. |
| protected abstract String | Returns: the qualifier if specified, otherwise empty String ornullthe method to inspect for executor qualifier metadata 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. |
| protected void | handleError(Throwable
the exception to handle ex, Method the method that was invoked method, Object... the parameters used to invoke the method params)Handles a fatal error thrown while asynchronously invoking the specified
|
| public void | setBeanFactory(BeanFactory
owning BeanFactory (never beanFactory)null).
The bean can immediately call methods on the factory.Implements org. BeanFactory to be used when looking up executors by qualifier
or when relying on the default executor lookup algorithm.
|
| public void | setExceptionHandler(AsyncUncaughtExceptionHandler exceptionHandler)
Supply the |
| public void | setExecutor(Executor
the defaultExecutor)Executor (typically a Spring AsyncTaskExecutor
or java.) 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 factorySupply the executor to be used when executing async methods. |
| beanFactory | back to summary |
|---|---|
| private BeanFactory beanFactory
| |
| DEFAULT_TASK_EXECUTOR_BEAN_NAME | back to summary |
|---|---|
| public static final String DEFAULT_TASK_EXECUTOR_BEAN_NAME The default name of the Note that the initial lookup happens by type; this is just the fallback in case of multiple executor beans found in the context.
| |
| defaultExecutor | back to summary |
|---|---|
| private SingletonSupplier<Executor> defaultExecutor | |
| embeddedValueResolver | back to summary |
|---|---|
| private StringValueResolver embeddedValueResolver
| |
| exceptionHandler | back to summary |
|---|---|
| private SingletonSupplier<AsyncUncaughtExceptionHandler> exceptionHandler | |
| executors | back to summary |
|---|---|
| private final Map<Method, AsyncTaskExecutor> executors | |
| logger | back to summary |
|---|---|
| protected final Log logger | |
| AsyncExecutionAspectSupport | back to summary |
|---|---|
| public AsyncExecutionAspectSupport(Executor defaultExecutor) Create a new instance with a default
| |
| AsyncExecutionAspectSupport | back to summary |
|---|---|
| public AsyncExecutionAspectSupport(Executor defaultExecutor, AsyncUncaughtExceptionHandler exceptionHandler) Create a new
| |
| configure | back to summary |
|---|---|
| public void configure(Supplier<Executor> defaultExecutor, Supplier<AsyncUncaughtExceptionHandler> exceptionHandler) Configure this aspect with the given executor and exception handler suppliers, applying the corresponding default if a supplier is not resolvable.
| |
| determineAsyncExecutor | back to summary |
|---|---|
| protected AsyncTaskExecutor determineAsyncExecutor(Method method) Determine the specific executor to use when executing the given method.
| |
| doSubmit | back to summary |
|---|---|
| protected Object doSubmit(Callable<Object> task, AsyncTaskExecutor executor, Class<?> returnType) Delegate for actually executing the given task with the chosen executor.
| |
| findQualifiedExecutor | back to summary |
|---|---|
| protected Executor findQualifiedExecutor(BeanFactory beanFactory, String qualifier) Retrieve a target executor for the given qualifier.
| |
| getDefaultExecutor | back to summary |
|---|---|
| protected Executor getDefaultExecutor(BeanFactory beanFactory) Retrieve or build a default executor for this advice instance. An executor returned from here will be cached for further use. The default implementation searches for a unique
| |
| getExecutorQualifier | back to summary |
|---|---|
| protected abstract String getExecutorQualifier(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
| |
| handleError | back to summary |
|---|---|
| protected void handleError(Throwable ex, Method method, Object... params) throws Exception Handles a fatal error thrown while asynchronously invoking the specified
If the return type of the method is a | |
| setBeanFactory | back to summary |
|---|---|
| public void setBeanFactory(BeanFactory beanFactory) Implements org. Set the
| |
| setExceptionHandler | back to summary |
|---|---|
| public void setExceptionHandler(AsyncUncaughtExceptionHandler exceptionHandler) Supply the | |
| setExecutor | back to summary |
|---|---|
| public void setExecutor(Executor defaultExecutor) Supply the executor to be used when executing async methods.
| |