Polish async request processing
This change fixes a cyclical package dependency. The change also improves the implementation of WebAsyncManager.hasConcurrentResult() following the resolution of Apache issue id=53632 and the release of Apache Tomcat 7.0.30 that contains the fix.
This commit is contained in:
@@ -20,23 +20,21 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Extends the HandlerInterceptor contract for scenarios where a handler may be
|
||||
* executed asynchronously. Since the handler will complete execution in another
|
||||
* thread, the results are not available in the current thread, and therefore the
|
||||
* DispatcherServlet exits quickly and on its way out invokes
|
||||
* {@link #afterConcurrentHandlingStarted(HttpServletRequest, HttpServletResponse)}
|
||||
* instead of {@code postHandle} and {@code afterCompletion}.
|
||||
* When the async handler execution completes, and the request is dispatched back
|
||||
* for further processing, the DispatcherServlet will invoke {@code preHandle}
|
||||
* again, as well as {@code postHandle} and {@code afterCompletion}.
|
||||
* Extends {@code HandlerInterceptor} with a callback method invoked during
|
||||
* asynchronous request handling.
|
||||
*
|
||||
* <p>Existing implementations should consider the fact that {@code preHandle} may
|
||||
* be invoked twice before {@code postHandle} and {@code afterCompletion} are
|
||||
* called if they don't implement this contract. Once before the start of concurrent
|
||||
* handling and a second time as part of an asynchronous dispatch after concurrent
|
||||
* handling is done. This may be not important in most cases but when some work
|
||||
* needs to be done after concurrent handling starts (e.g. clearing thread locals)
|
||||
* then this contract can be implemented.
|
||||
* <p>When a handler starts asynchronous request handling, the DispatcherServlet
|
||||
* exits without invoking {@code postHandle} and {@code afterCompletion}, as it
|
||||
* normally does, since the results of request handling (e.g. ModelAndView) are
|
||||
* not available in the current thread and handling is not yet complete.
|
||||
* In such scenarios, the
|
||||
* {@link #afterConcurrentHandlingStarted(HttpServletRequest, HttpServletResponse)}
|
||||
* method is invoked instead allowing implementations to perform tasks such as
|
||||
* cleaning up thread bound attributes.
|
||||
*
|
||||
* <p>When asynchronous handling completes, the request is dispatched to the
|
||||
* container for further processing. At this stage the DispatcherServlet invokes
|
||||
* {@code preHandle}, {@code postHandle} and {@code afterCompletion} as usual.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.2
|
||||
|
||||
@@ -20,8 +20,8 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.context.request.AsyncWebRequestInterceptor;
|
||||
import org.springframework.web.context.request.WebRequestInterceptor;
|
||||
import org.springframework.web.context.request.async.AsyncWebRequestInterceptor;
|
||||
import org.springframework.web.servlet.AsyncHandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user