public interface DeferredResultProcessingInterceptor
DeferredResult
to be set from a thread
chosen by the application (e.g. in response to some external event).
A DeferredResultProcessingInterceptor
is invoked before the start
of async processing, after the DeferredResult
is set as well as on
timeout, 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 HandlerExceptionResolver
mechanism.
The afterTimeout
method can set the DeferredResult
in order to resume processing.
Modifier and Type | Method and Description |
---|---|
<T> void |
afterCompletion(NativeWebRequest request,
DeferredResult<T> deferredResult)
Invoked from a container thread when an async request completed for any
reason including timeout and network error.
|
<T> void |
beforeConcurrentHandling(NativeWebRequest request,
DeferredResult<T> deferredResult)
Invoked immediately before the start of concurrent handling, in the same
thread that started it.
|
<T> boolean |
handleTimeout(NativeWebRequest request,
DeferredResult<T> deferredResult)
Invoked from a container thread when an async request times out before
the
DeferredResult has been set. |
<T> void |
postProcess(NativeWebRequest request,
DeferredResult<T> deferredResult,
java.lang.Object concurrentResult)
Invoked after a
DeferredResult has been set, via
DeferredResult.setResult(Object) or
DeferredResult.setErrorResult(Object) , and is also ready to
handle the concurrent result. |
<T> void |
preProcess(NativeWebRequest request,
DeferredResult<T> deferredResult)
Invoked immediately after the start of concurrent handling, in the same
thread that started it.
|
<T> void beforeConcurrentHandling(NativeWebRequest request, DeferredResult<T> deferredResult) throws java.lang.Exception
DeferredResult
.request
- the current requestdeferredResult
- the DeferredResult for the current requestjava.lang.Exception
- in case of errors<T> void preProcess(NativeWebRequest request, DeferredResult<T> deferredResult) throws java.lang.Exception
DeferredResult
.
The DeferredResult
may have already been set, for example at
the time of its creation or by another thread.
request
- the current requestdeferredResult
- the DeferredResult for the current requestjava.lang.Exception
- in case of errors<T> void postProcess(NativeWebRequest request, DeferredResult<T> deferredResult, java.lang.Object concurrentResult) throws java.lang.Exception
DeferredResult
has been set, via
DeferredResult.setResult(Object)
or
DeferredResult.setErrorResult(Object)
, and is also ready to
handle the concurrent result.
This method may also be invoked after a timeout when the
DeferredResult
was created with a constructor accepting a default
timeout result.
request
- the current requestdeferredResult
- the DeferredResult for the current requestconcurrentResult
- the result to which the DeferredResult
java.lang.Exception
- in case of errors<T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> deferredResult) throws java.lang.Exception
DeferredResult
has been set. Implementations may invoke
setResult
or
setErrorResult
to resume processing.request
- the current requestdeferredResult
- the DeferredResult for the current request; if the
DeferredResult
is set, then concurrent processing is resumed and
subsequent interceptors are not invokedtrue
if processing should continue, or false
if
other interceptors should not be invokedjava.lang.Exception
- in case of errors<T> void afterCompletion(NativeWebRequest request, DeferredResult<T> deferredResult) throws java.lang.Exception
DeferredResult
instance is no longer usable.request
- the current requestdeferredResult
- the DeferredResult for the current requestjava.lang.Exception
- in case of errors