public final class WebAsyncManager extends Object
An async scenario starts with request processing as usual in a thread (T1).
 Concurrent request handling can be initiated by calling
 startCallableProcessing or
 startDeferredResultProcessing,
 both of which produce a result in a separate thread (T2). The result is saved
 and the request dispatched to the container, to resume processing with the saved
 result in a third thread (T3). Within the dispatched thread (T3), the saved
 result can be accessed via getConcurrentResult() or its presence
 detected via hasConcurrentResult().
AsyncWebRequestInterceptor, 
AsyncHandlerInterceptor, 
OncePerRequestFilter.shouldNotFilterAsyncDispatch(), 
OncePerRequestFilter.isAsyncDispatch(javax.servlet.http.HttpServletRequest)| Modifier and Type | Method and Description | 
|---|---|
| void | clearConcurrentResult()Clear concurrentResult and
 concurrentResultContext. | 
| CallableProcessingInterceptor | getCallableInterceptor(Object key)Get the  CallableProcessingInterceptorregistered under the given key. | 
| Object | getConcurrentResult()Provides access to the result from concurrent handling. | 
| Object[] | getConcurrentResultContext()Provides access to additional processing context saved at the start of
 concurrent handling. | 
| DeferredResultProcessingInterceptor | getDeferredResultInterceptor(Object key)Get the  DeferredResultProcessingInterceptorregistered under the given key. | 
| boolean | hasConcurrentResult()Whether a result value exists as a result of concurrent handling. | 
| boolean | isConcurrentHandlingStarted()Whether the selected handler for the current request chose to handle the
 request asynchronously. | 
| void | registerCallableInterceptor(Object key,
                           CallableProcessingInterceptor interceptor)Register a  CallableProcessingInterceptorunder the given key. | 
| void | registerCallableInterceptors(CallableProcessingInterceptor... interceptors)Register a  CallableProcessingInterceptorwithout a key. | 
| void | registerDeferredResultInterceptor(Object key,
                                 DeferredResultProcessingInterceptor interceptor)Register a  DeferredResultProcessingInterceptorunder the given key. | 
| void | registerDeferredResultInterceptors(DeferredResultProcessingInterceptor... interceptors)Register one or more  DeferredResultProcessingInterceptors without a specified key. | 
| void | setAsyncWebRequest(AsyncWebRequest asyncWebRequest)Configure the  AsyncWebRequestto use. | 
| void | setTaskExecutor(AsyncTaskExecutor taskExecutor)Configure an AsyncTaskExecutor for use with concurrent processing via
  startCallableProcessing(Callable, Object...). | 
| void | startCallableProcessing(Callable<?> callable,
                       Object... processingContext)Start concurrent request processing and execute the given task with an
  AsyncTaskExecutor. | 
| void | startCallableProcessing(WebAsyncTask<?> webAsyncTask,
                       Object... processingContext)Use the given  WebAsyncTaskto configure the task executor as well as
 the timeout value of theAsyncWebRequestbefore delegating tostartCallableProcessing(Callable, Object...). | 
| void | startDeferredResultProcessing(DeferredResult<?> deferredResult,
                             Object... processingContext)Start concurrent request processing and initialize the given
  DeferredResultwith aDeferredResult.DeferredResultHandlerthat saves
 the result and dispatches the request to resume processing of that
 result. | 
public void setAsyncWebRequest(AsyncWebRequest asyncWebRequest)
AsyncWebRequest to use. This property may be set
 more than once during a single request to accurately reflect the current
 state of the request (e.g. following a forward, request/response
 wrapping, etc). However, it should not be set while concurrent handling
 is in progress, i.e. while isConcurrentHandlingStarted() is
 true.asyncWebRequest - the web request to usepublic void setTaskExecutor(AsyncTaskExecutor taskExecutor)
startCallableProcessing(Callable, Object...).
 By default a SimpleAsyncTaskExecutor instance is used.
public boolean isConcurrentHandlingStarted()
public boolean hasConcurrentResult()
public Object getConcurrentResult()
Exception or Throwable if
 concurrent handling raised one.clearConcurrentResult()public Object[] getConcurrentResultContext()
clearConcurrentResult()public CallableProcessingInterceptor getCallableInterceptor(Object key)
CallableProcessingInterceptor registered under the given key.key - the keynull if nonepublic DeferredResultProcessingInterceptor getDeferredResultInterceptor(Object key)
DeferredResultProcessingInterceptor registered under the given key.key - the keynull if nonepublic void registerCallableInterceptor(Object key, CallableProcessingInterceptor interceptor)
CallableProcessingInterceptor under the given key.key - the keyinterceptor - the interceptor to registerpublic void registerCallableInterceptors(CallableProcessingInterceptor... interceptors)
CallableProcessingInterceptor without a key.
 The key is derived from the class name and hashcode.interceptors - one or more interceptors to registerpublic void registerDeferredResultInterceptor(Object key, DeferredResultProcessingInterceptor interceptor)
DeferredResultProcessingInterceptor under the given key.key - the keyinterceptor - the interceptor to registerpublic void registerDeferredResultInterceptors(DeferredResultProcessingInterceptor... interceptors)
DeferredResultProcessingInterceptors without a specified key.
 The default key is derived from the interceptor class name and hash code.interceptors - one or more interceptors to registerpublic void clearConcurrentResult()
public void startCallableProcessing(Callable<?> callable, Object... processingContext) throws Exception
AsyncTaskExecutor. The result
 from the task execution is saved and the request dispatched in order to
 resume processing of that result. If the task raises an Exception then
 the saved result will be the raised Exception.callable - a unit of work to be executed asynchronouslyprocessingContext - additional context to save that can be accessed
 via getConcurrentResultContext()Exception - if concurrent processing failed to startgetConcurrentResult(), 
getConcurrentResultContext()public void startCallableProcessing(WebAsyncTask<?> webAsyncTask, Object... processingContext) throws Exception
WebAsyncTask to configure the task executor as well as
 the timeout value of the AsyncWebRequest before delegating to
 startCallableProcessing(Callable, Object...).webAsyncTask - a WebAsyncTask containing the target CallableprocessingContext - additional context to save that can be accessed
 via getConcurrentResultContext()Exception - if concurrent processing failed to startpublic void startDeferredResultProcessing(DeferredResult<?> deferredResult, Object... processingContext) throws Exception
DeferredResult with a DeferredResult.DeferredResultHandler that saves
 the result and dispatches the request to resume processing of that
 result. The AsyncWebRequest is also updated with a completion
 handler that expires the DeferredResult and a timeout handler
 assuming the DeferredResult has a default timeout result.deferredResult - the DeferredResult instance to initializeprocessingContext - additional context to save that can be accessed
 via getConcurrentResultContext()Exception - if concurrent processing failed to startgetConcurrentResult(), 
getConcurrentResultContext()