public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport implements Ordered
MethodInterceptorthat processes method invocations asynchronously, using a given
AsyncTaskExecutor. Typically used with the
In terms of target method signatures, any parameter types are supported.
However, the return type is constrained to either
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
or EJB 3.1's
When the return type is
java.util.concurrent.Future, any exception thrown
during the execution can be accessed and managed by the caller. With
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
|Constructor and Description|
Create a new instance with a default
Create a new
|Modifier and Type||Method and Description|
This implementation is a no-op for compatibility in Spring 3.1.2.
Return the order value of this object, with a higher value meaning greater in terms of sorting.
Intercept the given method invocation, submit the actual calling of the method to the correct task executor and return immediately to the caller.
determineAsyncExecutor, doSubmit, handleError, setBeanFactory, setExceptionHandler, setExecutor
public AsyncExecutionInterceptor(java.util.concurrent.Executor defaultExecutor, AsyncUncaughtExceptionHandler exceptionHandler)
Executor(typically a Spring
ExecutorService) to delegate to
public AsyncExecutionInterceptor(java.util.concurrent.Executor defaultExecutor)
public java.lang.Object invoke(MethodInvocation invocation) throws java.lang.Throwable
invocation- the method to intercept and make asynchronous
Futureif the original method returns
protected java.lang.String getExecutorQualifier(java.lang.reflect.Method method)
method- the method to inspect for executor qualifier metadata
public int getOrder()
Normally starting with 0, with
indicating the greatest value. Same order values will result
in arbitrary positions for the affected objects.
Higher values can be interpreted as lower priority. As a consequence, the object with the lowest value has highest priority (somewhat analogous to Servlet "load-on-startup" values).