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.servlet
Interface AsyncHandlerInterceptor

All Superinterfaces:
  HandlerInterceptor

All Known Implementing Classes:
  WebRequestHandlerInterceptorAdapter

    public interface AsyncHandlerInterceptor

extends HandlerInterceptor

Extends `HanderInterceptor` with lifecycle methods specific to async request processing.

This is the sequence of events on the main thread in an async scenario:

1. `#preHandle(WebRequest)`
2. `#getAsyncCallable(WebRequest)`
3. ... handler execution
4. `#postHandleAsyncStarted(WebRequest)`

This is the sequence of events on the async thread:

1. Async `Callable.call()` (the `Callable` returned by `getAsyncCallable`)
2. ... async handler execution
3. `#postHandle(WebRequest, org.springframework.ui.ModelMap)`
4. `#afterCompletion(WebRequest, Exception)`

Since:
  3.2
Author:
  Rossen Stoyanchev

Method Summary
`AbstractDelegatingCallable` | `getAsyncCallable(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler)` Invoked after `#preHandle(WebRequest)` and before the handler is executed.
`void` | `postHandleAsyncStarted(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler)` Invoked after the execution of a handler if the handler started async processing instead of handling the request.

Methods inherited from interface org.springframework.web.servlet.HandlerInterceptor
`afterCompletion, postHandle, preHandle`

Method Detail

### getAsyncCallable

    AbstractDelegatingCallable getAsyncCallable(javax.servlet.http.HttpServletRequest request,
                                                javax.servlet.http.HttpServletResponse response,
                                                java.lang.Object handler)

  Invoked after `#preHandle(WebRequest)` and before the handler is executed. The returned `Callable` is used only if handler execution leads to teh start of async processing. It is invoked the async thread before the request is handled fro.

  Implementations can use this `Callable` to initialize ThreadLocal attributes on the async thread.

  Parameters:
    `request` - current HTTP request
    `response` - current HTTP response
    `handler` - chosen handler to execute, for type and/or instance examination
  Returns:
    a `Callable` instance or `null`

### postHandleAsyncStarted

    void postHandleAsyncStarted(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response,
                                java.lang.Object handler)

  Invoked after the execution of a handler if the handler started async processing instead of handling the request. Effectively this method is invoked on the way out of the main processing thread instead of `#postHandle(WebRequest, org.springframework.ui.ModelMap)`. The `postHandle` method is invoked after the request is handled in the async thread.

  Implementations of this method can ensure ThreadLocal attributes bound to the main thread are cleared and also prepare for binding them to the async thread.

  Parameters:
    `request` - current HTTP request
    `response` - current HTTP response
    `handler` - chosen handler to execute, for type and/or instance examination

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