org.springframework.web.servlet

## Interface AsyncHandlerInterceptor

- All Superinterfaces:
    HandlerInterceptor
  All Known Implementing Classes:
    ConversionServiceExposingInterceptor, HandlerInterceptorAdapter, LocaleChangeInterceptor, ThemeChangeInterceptor, UserRoleAuthorizationInterceptor, WebRequestHandlerInterceptorAdapter

      public interface AsyncHandlerInterceptor
      extends HandlerInterceptor

  Extends `HandlerInterceptor` with a callback method invoked during asynchronous request handling.

  When a handler starts asynchronous request handling, the DispatcherServlet exits without invoking `postHandle` and `afterCompletion`, as it normally does, since the results of request handling (e.g. ModelAndView) will. be produced concurrently in another thread. In such scenarios, `afterConcurrentHandlingStarted(HttpServletRequest, HttpServletResponse, Object)` is invoked instead allowing implementations to perform tasks such as cleaning up thread bound attributes.

  When asynchronous handling completes, the request is dispatched to the container for further processing. At this stage the DispatcherServlet invokes `preHandle`, `postHandle` and `afterCompletion` as usual.

  Since:
    3.2
  Author:
    Rossen Stoyanchev
  See Also:
    `WebAsyncManager`, `CallableProcessingInterceptor`, `DeferredResultProcessingInterceptor`

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler)` Called instead of `postHandle` and `afterCompletion`, when the a handler is being executed concurrently.

    - ### Methods inherited from interface org.springframework.web.servlet.HandlerInterceptor

      `afterCompletion, postHandle, preHandle`

- - ### Method Detail

    - #### afterConcurrentHandlingStarted

          void afterConcurrentHandlingStarted(HttpServletRequest request,
                                            HttpServletResponse response,
                                            Object handler)
                                              throws Exception

      Called instead of `postHandle` and `afterCompletion`, when the a handler is being executed concurrently. Implementations may use the provided request and response but should avoid modifying them in ways that would conflict with the concurrent execution of the handler. A typical use of this method would be to clean thread local variables.
      Parameters:
        `request` - the current request
        `response` - the current response
        `handler` - handler (or `HandlerMethod`) that started async execution, for type and/or instance examination
      Throws:
        `Exception` - in case of errors