Interface DeferredResultProcessingInterceptor
- All Known Implementing Classes:
- TimeoutDeferredResultProcessingInterceptor
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.
- Since:
- 3.2
- Author:
- Rossen Stoyanchev, Rob Winch
- 
Method SummaryModifier and TypeMethodDescriptiondefault <T> voidafterCompletion(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> voidbeforeConcurrentHandling(NativeWebRequest request, DeferredResult<T> deferredResult) Invoked immediately before the start of concurrent handling, in the same thread that started it.default <T> booleanhandleError(NativeWebRequest request, DeferredResult<T> deferredResult, Throwable t) Invoked from a container thread when an error occurred while processing an async request before theDeferredResulthas been set.default <T> booleanhandleTimeout(NativeWebRequest request, DeferredResult<T> deferredResult) Invoked from a container thread when an async request times out before theDeferredResulthas been set.default <T> voidpostProcess(NativeWebRequest request, DeferredResult<T> deferredResult, Object concurrentResult) Invoked after aDeferredResulthas been set, viaDeferredResult.setResult(Object)orDeferredResult.setErrorResult(Object), and is also ready to handle the concurrent result.default <T> voidpreProcess(NativeWebRequest request, DeferredResult<T> deferredResult) Invoked immediately after the start of concurrent handling, in the same thread that started it.
- 
Method Details- 
beforeConcurrentHandlingdefault <T> void beforeConcurrentHandling(NativeWebRequest request, DeferredResult<T> deferredResult) throws Exception Invoked immediately before the start of concurrent handling, in the same thread that started it. This method may be used to capture state just prior to the start of concurrent processing with the givenDeferredResult.- Parameters:
- request- the current request
- deferredResult- the DeferredResult for the current request
- Throws:
- Exception- in case of errors
 
- 
preProcessdefault <T> void preProcess(NativeWebRequest request, DeferredResult<T> deferredResult) throws Exception Invoked immediately after the start of concurrent handling, in the same thread that started it. This method may be used to detect the start of concurrent processing with the givenDeferredResult.The DeferredResultmay have already been set, for example at the time of its creation or by another thread.- Parameters:
- request- the current request
- deferredResult- the DeferredResult for the current request
- Throws:
- Exception- in case of errors
 
- 
postProcessdefault <T> void postProcess(NativeWebRequest request, DeferredResult<T> deferredResult, Object concurrentResult) throws Exception Invoked after aDeferredResulthas been set, viaDeferredResult.setResult(Object)orDeferredResult.setErrorResult(Object), and is also ready to handle the concurrent result.This method may also be invoked after a timeout when the DeferredResultwas created with a constructor accepting a default timeout result.- Parameters:
- request- the current request
- deferredResult- the DeferredResult for the current request
- concurrentResult- the result to which the- DeferredResult
- Throws:
- Exception- in case of errors
 
- 
handleTimeoutdefault <T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> deferredResult) throws Exception Invoked from a container thread when an async request times out before theDeferredResulthas been set. Implementations may invokesetResultorsetErrorResultto resume processing.- Parameters:
- request- the current request
- deferredResult- the DeferredResult for the current request; if the- DeferredResultis set, then concurrent processing is resumed and subsequent interceptors are not invoked
- Returns:
- trueif processing should continue, or- falseif other interceptors should not be invoked
- Throws:
- Exception- in case of errors
 
- 
handleErrordefault <T> boolean handleError(NativeWebRequest request, DeferredResult<T> deferredResult, Throwable t) throws Exception Invoked from a container thread when an error occurred while processing an async request before theDeferredResulthas been set. Implementations may invokesetResultorsetErrorResultto resume processing.- Parameters:
- request- the current request
- deferredResult- the DeferredResult for the current request; if the- DeferredResultis set, then concurrent processing is resumed and subsequent interceptors are not invoked
- t- the error that occurred while request processing
- Returns:
- trueif error handling should continue, or- falseif other interceptors should be bypassed and not be invoked
- Throws:
- Exception- in case of errors
 
- 
afterCompletiondefault <T> void afterCompletion(NativeWebRequest request, DeferredResult<T> deferredResult) throws Exception Invoked from a container thread when an async request completed for any reason including timeout and network error. This method is useful for detecting that aDeferredResultinstance is no longer usable.- Parameters:
- request- the current request
- deferredResult- the DeferredResult for the current request
- Throws:
- Exception- in case of errors
 
 
-