Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.web.context.request.async
Class AsyncExecutionChain

    java.lang.Object
      org.springframework.web.context.request.async.AsyncExecutionChain

    public final class AsyncExecutionChain

extends java.lang.Object

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.

Since:
  3.2
Author:
  Rossen Stoyanchev

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(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

### CALLABLE_CHAIN_ATTRIBUTE

    public static final java.lang.String CALLABLE_CHAIN_ATTRIBUTE

Method Detail

### getForCurrentRequest

    public static AsyncExecutionChain getForCurrentRequest(javax.servlet.ServletRequest request)

  Obtain the AsyncExecutionChain for the current request. Or if not found, create an instance and associate it with the request.

### getForCurrentRequest

    public static AsyncExecutionChain getForCurrentRequest(WebRequest request)

  Obtain the AsyncExecutionChain for the current request. Or if not found, create an instance and associate it with the request.

### setAsyncWebRequest

    public void setAsyncWebRequest(AsyncWebRequest asyncRequest)

  Provide an instance of an AsyncWebRequest. This property must be set before async request processing can begin.

### setTaskExecutor

    public void setTaskExecutor(AsyncTaskExecutor taskExecutor)

  Provide an AsyncTaskExecutor to use when `startCallableChainProcessing()` is invoked, for example when a controller method returns a Callable.

  By default a `SimpleAsyncTaskExecutor` instance is used.

### isAsyncStarted

    public boolean isAsyncStarted()

  Whether async request processing has started through one of:
  - `startCallableChainProcessing()`
  - `startDeferredResultProcessing(DeferredResult)`

### addDelegatingCallable

    public void addDelegatingCallable(AbstractDelegatingCallable callable)

  Add a Callable with logic required to complete request processing in a separate thread. See `AbstractDelegatingCallable` for details.

### setCallable

    public AsyncExecutionChain setCallable(java.util.concurrent.Callable<java.lang.Object> callable)

  Add the last Callable, for example the one returned by the controller. This property must be set prior to invoking `startCallableChainProcessing()`.

### startCallableChainProcessing

    public void startCallableChainProcessing()

  Start the async execution chain by submitting an `AsyncExecutionChainRunnable` instance to the TaskExecutor provided via `setTaskExecutor(AsyncTaskExecutor)` and returning immediately.

  See Also:
    `AsyncExecutionChainRunnable`

### startDeferredResultProcessing

    public 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`.

  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.

  See Also:
    `DeferredResult`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD