接口 CallableProcessingInterceptor
- 所有已知实现类:
TimeoutAsyncProcessingInterceptor
Callable on behalf of the application with
an AsyncTaskExecutor.
A CallableProcessingInterceptor is invoked before and after the
invocation of the Callable task in the asynchronous thread, as well
as on timeout/error from a container thread, or after completing for any reason
including a timeout or network error.
As a general rule exceptions raised by interceptor methods will cause
async processing to resume by dispatching back to the container and using
the Exception instance as the concurrent result. Such exceptions will then
be processed through the HandlerExceptionHandler mechanism.
The handleTimeout method
can select a value to be used to resume processing.
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Rob Winch
-
字段概要
字段修饰符和类型字段说明static final ObjectConstant indicating that the response has been handled by this interceptor without a result and that no further interceptors are to be invoked.static final ObjectConstant indicating that no result has been determined by this interceptor, giving subsequent interceptors a chance. -
方法概要
修饰符和类型方法说明default <T> voidafterCompletion(RequestContext request, Callable<T> task) Invoked from a container thread when async processing completes for any reason including timeout or network error.default <T> voidbeforeConcurrentHandling(RequestContext request, Callable<T> task) Invoked before the start of concurrent handling in the original thread in which theCallableis submitted for concurrent handling.default <T> ObjecthandleError(RequestContext request, Callable<T> task, Throwable t) Invoked from a container thread when an error occurred while processing the async request before theCallabletask completes.default <T> ObjecthandleTimeout(RequestContext request, Callable<T> task) Invoked from a container thread when the async request times out before theCallabletask completes.default <T> voidpostProcess(RequestContext request, Callable<T> task, Object concurrentResult) Invoked after theCallablehas produced a result in the async thread in which theCallableis executed.default <T> voidpreProcess(RequestContext request, Callable<T> task) Invoked after the start of concurrent handling in the async thread in which theCallableis executed and before the actual invocation of theCallable.
-
字段详细资料
-
RESULT_NONE
Constant indicating that no result has been determined by this interceptor, giving subsequent interceptors a chance. -
RESPONSE_HANDLED
Constant indicating that the response has been handled by this interceptor without a result and that no further interceptors are to be invoked.
-
-
方法详细资料
-
beforeConcurrentHandling
default <T> void beforeConcurrentHandling(RequestContext request, Callable<T> task) throws Exception Invoked before the start of concurrent handling in the original thread in which theCallableis submitted for concurrent handling.This is useful for capturing the state of the current thread just prior to invoking the
Callable. Once the state is captured, it can then be transferred to the newThreadinpreProcess(RequestContext, Callable). Capturing the state of Infra Security's SecurityContextHolder and migrating it to the new Thread is a concrete example of where this is useful.The default implementation is empty.
- 参数:
request- the current requesttask- the task for the current async request- 抛出:
Exception- in case of errors
-
preProcess
Invoked after the start of concurrent handling in the async thread in which theCallableis executed and before the actual invocation of theCallable.The default implementation is empty.
- 参数:
request- the current requesttask- the task for the current async request- 抛出:
Exception- in case of errors
-
postProcess
default <T> void postProcess(RequestContext request, Callable<T> task, Object concurrentResult) throws Exception Invoked after theCallablehas produced a result in the async thread in which theCallableis executed. This method may be invoked later thanafterTimeoutorafterCompletiondepending on when theCallablefinishes processing.The default implementation is empty.
-
handleTimeout
Invoked from a container thread when the async request times out before theCallabletask completes. Implementations may return a value, including anException, to use instead of the value theCallabledid not return in time.The default implementation always returns
RESULT_NONE.- 参数:
request- the current requesttask- the task for the current async request- 返回:
- a concurrent result value; if the value is anything other than
RESULT_NONEorRESPONSE_HANDLED, concurrent processing is resumed and subsequent interceptors are not invoked - 抛出:
Exception- in case of errors
-
handleError
default <T> Object handleError(RequestContext request, Callable<T> task, Throwable t) throws Exception Invoked from a container thread when an error occurred while processing the async request before theCallabletask completes. Implementations may return a value, including anException, to use instead of the value theCallabledid not return in time.The default implementation always returns
RESULT_NONE.- 参数:
request- the current requesttask- the task for the current async requestt- the error that occurred while request processing- 返回:
- a concurrent result value; if the value is anything other than
RESULT_NONEorRESPONSE_HANDLED, concurrent processing is resumed and subsequent interceptors are not invoked - 抛出:
Exception- in case of errors
-
afterCompletion
Invoked from a container thread when async processing completes for any reason including timeout or network error.The default implementation is empty.
- 参数:
request- the current requesttask- the task for the current async request- 抛出:
Exception- in case of errors
-