Async annotation at class or
method-level by adding a corresponding AsyncAnnotationAdvisor to the
exposed proxy (either an existing AOP proxy or a newly generated proxy that
implements all the target's interfaces).
The TaskExecutor responsible for the asynchronous execution may
be provided as well as the annotation type that indicates a method should be
invoked asynchronously. If no annotation type is specified, this post-
processor will detect both Spring's @Async annotation as well
as the EJB 3.1 jakarta.ejb.Asynchronous annotation.
For methods having a void return type, any exception thrown
during the asynchronous method invocation cannot be accessed by the
caller. An AsyncUncaughtExceptionHandler can be specified to handle
these cases.
Note
The underlying async advisor applies before existing advisors by default, in order to switch to async execution as early as possible in the invocation chain.
Async, AsyncAnnotationAdvisor, setBeforeExistingAdvisors, ScheduledAnnotationBeanPostProcessor
| Modifier and Type | Field and Description |
|---|---|
| private Class | |
| public static final String | DEFAULT_TASK_EXECUTOR_BEAN_NAME
The default name of the |
| private Supplier | |
| private Supplier | |
| protected final Log |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | configure(Supplier<Executor> executor, Supplier<AsyncUncaughtExceptionHandler> exceptionHandler)
Configure this post-processor with the given executor and exception handler suppliers, applying the corresponding default if a supplier is not resolvable. |
| public void | setAsyncAnnotationType(Class<? extends Annotation>
the desired annotation type asyncAnnotationType)Set the 'async' annotation type to be detected at either class or method level. |
| public void | setBeanFactory(BeanFactory
owning BeanFactory (never beanFactory)
null).
The bean can immediately call methods on the factory.Implements org. |
| public void | setExceptionHandler(AsyncUncaughtExceptionHandler exceptionHandler)
Set the |
| public void |
| asyncAnnotationType | back to summary |
|---|---|
| private Class<? extends Annotation> asyncAnnotationType
| |
| 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.
| |
| exceptionHandler | back to summary |
|---|---|
| private Supplier<AsyncUncaughtExceptionHandler> exceptionHandler
| |
| executor | back to summary |
|---|---|
| private Supplier<Executor> executor
| |
| logger | back to summary |
|---|---|
| protected final Log logger | |
| AsyncAnnotationBeanPostProcessor | back to summary |
|---|---|
| public AsyncAnnotationBeanPostProcessor() | |
| configure | back to summary |
|---|---|
| public void configure(Supplier<Executor> executor, Supplier<AsyncUncaughtExceptionHandler> exceptionHandler) Configure this post-processor with the given executor and exception handler suppliers, applying the corresponding default if a supplier is not resolvable.
| |
| setAsyncAnnotationType | back to summary |
|---|---|
| public void setAsyncAnnotationType(Class<? extends Annotation> asyncAnnotationType) Set the 'async' annotation type to be detected at either class or method
level. By default, both the This setter property exists so that developers can provide their own (non-Spring-specific) annotation type to indicate that a method (or all methods of a given class) should be invoked asynchronously.
| |
| setBeanFactory | back to summary |
|---|---|
| public void setBeanFactory(BeanFactory beanFactory) Implements org. Doc from org. Callback that supplies the owning factory to a bean instance. Invoked after the population of normal bean properties
but before an initialization callback such as
| |
| setExceptionHandler | back to summary |
|---|---|
| public void setExceptionHandler(AsyncUncaughtExceptionHandler exceptionHandler) Set the
| |
| setExecutor | back to summary |
|---|---|
| public void setExecutor(Executor executor) Set the If not specified, default executor resolution will apply: searching for a
unique | |