|
spring-web | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.web.context.request.async.AsyncExecutionChain
public final class AsyncExecutionChain
The central class for managing async request processing, mainly intended as an SPI and typically not by non-framework classes.
An async execution chain consists of a sequence of Callable instances and
represents the work required to complete request processing in a separate
thread. To construct the chain, each layer in the call stack of a normal
request (e.g. filter, servlet) may contribute an
AbstractDelegatingCallable
when a request is being processed.
For example the DispatcherServlet might contribute a Callable that
performs view resolution while a HandlerAdapter might contribute a Callable
that returns the ModelAndView, etc. The last Callable is the one that
actually produces an application-specific value, for example the Callable
returned by an @RequestMapping
method.
Field Summary | |
---|---|
static java.lang.String |
CALLABLE_CHAIN_ATTRIBUTE
|
Method Summary | |
---|---|
void |
addDelegatingCallable(AbstractDelegatingCallable callable)
Add a Callable with logic required to complete request processing in a separate thread. |
static AsyncExecutionChain |
getForCurrentRequest(javax.servlet.ServletRequest request)
Obtain the AsyncExecutionChain for the current request. |
static AsyncExecutionChain |
getForCurrentRequest(WebRequest request)
Obtain the AsyncExecutionChain for the current request. |
boolean |
isAsyncStarted()
Whether async request processing has started through one of: startCallableChainProcessing()
startDeferredResultProcessing(DeferredResult)
|
void |
setAsyncWebRequest(AsyncWebRequest asyncRequest)
Provide an instance of an AsyncWebRequest. |
AsyncExecutionChain |
setCallable(java.util.concurrent.Callable<java.lang.Object> callable)
Add the last Callable, for example the one returned by the controller. |
void |
setTaskExecutor(org.springframework.core.task.AsyncTaskExecutor taskExecutor)
Provide an AsyncTaskExecutor to use when startCallableChainProcessing() is invoked, for example when a
controller method returns a Callable. |
void |
startCallableChainProcessing()
Start the async execution chain by submitting an AsyncExecutionChainRunnable instance to the TaskExecutor provided via
setTaskExecutor(AsyncTaskExecutor) and returning immediately. |
void |
startDeferredResultProcessing(DeferredResult deferredResult)
Mark the start of async request processing accepting the provided DeferredResult and initializing it such that if DeferredResult.set(Object) is called (from another thread),
the set Object value will be processed with the execution chain by
invoking AsyncExecutionChainRunnable . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CALLABLE_CHAIN_ATTRIBUTE
Method Detail |
---|
public static AsyncExecutionChain getForCurrentRequest(javax.servlet.ServletRequest request)
public static AsyncExecutionChain getForCurrentRequest(WebRequest request)
public void setAsyncWebRequest(AsyncWebRequest asyncRequest)
public void setTaskExecutor(org.springframework.core.task.AsyncTaskExecutor taskExecutor)
startCallableChainProcessing()
is invoked, for example when a
controller method returns a Callable.
By default a SimpleAsyncTaskExecutor
instance is used.
public boolean isAsyncStarted()
public void addDelegatingCallable(AbstractDelegatingCallable callable)
AbstractDelegatingCallable
for details.
public AsyncExecutionChain setCallable(java.util.concurrent.Callable<java.lang.Object> callable)
startCallableChainProcessing()
.
public void startCallableChainProcessing()
AsyncExecutionChainRunnable
instance to the TaskExecutor provided via
setTaskExecutor(AsyncTaskExecutor)
and returning immediately.
AsyncExecutionChainRunnable
public void startDeferredResultProcessing(DeferredResult deferredResult)
DeferredResult.set(Object)
is called (from another thread),
the set Object value will be processed with the execution chain by
invoking AsyncExecutionChainRunnable
.
The resulting processing from this method is identical to
startCallableChainProcessing()
. The main difference is in
the threading model, i.e. whether a TaskExecutor is used.
DeferredResult
|
spring-web | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |