open class AsyncExecutionInterceptor : AsyncExecutionAspectSupport, MethodInterceptor, Ordered
AOP Alliance MethodInterceptor that processes method invocations asynchronously, using a given org.springframework.core.task.AsyncTaskExecutor. Typically used with the org.springframework.scheduling.annotation.Async annotation.
In terms of target method signatures, any parameter types are supported. However, the return type is constrained to either void or java.util.concurrent.Future. In the latter case, the Future handle returned from the proxy will be an actual asynchronous Future that can be used to track the result of the asynchronous method execution. However, since the target method needs to implement the same signature, it will have to return a temporary Future handle that just passes the return value through (like Spring's org.springframework.scheduling.annotation.AsyncResult or EJB 3.1's javax.ejb.AsyncResult).
When the return type is java.util.concurrent.Future, any exception thrown during the execution can be accessed and managed by the caller. With void return type however, such exceptions cannot be transmitted back. In that case an AsyncUncaughtExceptionHandler can be registered to process such exceptions.
As of Spring 3.1.2 the AnnotationAsyncExecutionInterceptor subclass is preferred for use due to its support for executor qualification in conjunction with Spring's @Async annotation.
Author
Juergen Hoeller
Author
Chris Beams
Author
Stephane Nicoll
Since
3.0
See Also
org.springframework.scheduling.annotation.Asyncorg.springframework.scheduling.annotation.AsyncAnnotationAdvisororg.springframework.scheduling.annotation.AnnotationAsyncExecutionInterceptor
AsyncExecutionInterceptor(defaultExecutor: Executor)
Create a new instance with a default AsyncUncaughtExceptionHandler. AsyncExecutionInterceptor(defaultExecutor: Executor, exceptionHandler: AsyncUncaughtExceptionHandler)
Create a new |
static val DEFAULT_TASK_EXECUTOR_BEAN_NAME: String
The default name of the TaskExecutor bean to pick up: "taskExecutor". Note that the initial lookup happens by type; this is just the fallback in case of multiple executor beans found in the context. |
open fun getOrder(): Int |
|
open fun invoke(invocation: MethodInvocation): Any
Intercept the given method invocation, submit the actual calling of the method to the correct task executor and return immediately to the caller. |
open fun setBeanFactory(beanFactory: BeanFactory): Unit
Set the BeanFactory to be used when looking up executors by qualifier or when relying on the default executor lookup algorithm. |
|
open fun setExceptionHandler(exceptionHandler: AsyncUncaughtExceptionHandler): Unit
Supply the AsyncUncaughtExceptionHandler to use to handle exceptions thrown by invoking asynchronous methods with a |
|
open fun setExecutor(defaultExecutor: Executor): Unit
Supply the executor to be used when executing async methods. |
open class AnnotationAsyncExecutionInterceptor : AsyncExecutionInterceptor
Specialization of AsyncExecutionInterceptor that delegates method execution to an |