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/error, 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 handleTimeout
method can set the DeferredResult
in order to resume processing.
Modifier and Type | Method and Description |
---|---|
default <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.
|
default <T> void |
beforeConcurrentHandling(NativeWebRequest request,
DeferredResult<T> deferredResult)
Invoked immediately before the start of concurrent handling, in the same
thread that started it.
|
default <T> boolean |
handleError(NativeWebRequest request,
DeferredResult<T> deferredResult,
Throwable t)
Invoked from a container thread when an error occurred while processing an async request
before the
DeferredResult has been set. |
default <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. |
default <T> void |
postProcess(NativeWebRequest request,
DeferredResult<T> deferredResult,
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. |
default <T> void |
preProcess(NativeWebRequest request,
DeferredResult<T> deferredResult)
Invoked immediately after the start of concurrent handling, in the same
thread that started it.
|
default <T> void beforeConcurrentHandling(NativeWebRequest request, DeferredResult<T> deferredResult) throws Exception
DeferredResult
.request
- the current requestdeferredResult
- the DeferredResult for the current requestException
- in case of errorsdefault <T> void preProcess(NativeWebRequest request, DeferredResult<T> deferredResult) throws 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 requestException
- in case of errorsdefault <T> void postProcess(NativeWebRequest request, DeferredResult<T> deferredResult, Object concurrentResult) throws 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
Exception
- in case of errorsdefault <T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> deferredResult) throws 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 invokedException
- in case of errorsdefault <T> boolean handleError(NativeWebRequest request, DeferredResult<T> deferredResult, Throwable t) throws 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 invokedt
- the error that occurred while request processingtrue
if error handling should continue, or false
if
other interceptors should by bypassed and not be invokedException
- in case of errorsdefault <T> void afterCompletion(NativeWebRequest request, DeferredResult<T> deferredResult) throws Exception
DeferredResult
instance is no longer usable.request
- the current requestdeferredResult
- the DeferredResult for the current requestException
- in case of errors