Spring Framework

org.springframework.web.context.request.async
Interface AsyncWebRequestInterceptor

All Superinterfaces:
WebRequestInterceptor
All Known Implementing Classes:
OpenSessionInViewInterceptor, OpenSessionInViewInterceptor

public interface AsyncWebRequestInterceptor
extends WebRequestInterceptor

Extends WebRequestInterceptor with lifecycle methods specific to async request processing.

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

  1. WebRequestInterceptor.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. WebRequestInterceptor.postHandle(WebRequest, org.springframework.ui.ModelMap)
  4. WebRequestInterceptor.afterCompletion(WebRequest, Exception)

Since:
3.2
Author:
Rossen Stoyanchev

Method Summary
 AbstractDelegatingCallable getAsyncCallable(WebRequest request)
          Invoked after WebRequestInterceptor.preHandle(WebRequest) and before the handler is executed.
 void postHandleAsyncStarted(WebRequest request)
          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.context.request.WebRequestInterceptor
afterCompletion, postHandle, preHandle
 

Method Detail

getAsyncCallable

AbstractDelegatingCallable getAsyncCallable(WebRequest request)
Invoked after WebRequestInterceptor.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.

Returns:
a Callable instance or null

postHandleAsyncStarted

void postHandleAsyncStarted(WebRequest request)
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 WebRequestInterceptor.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.


Spring Framework