Polish async support
Added handler argument to the signature of AsyncHandlerInterceptor.afterConcurrentHandlingStarted(..). Renamed AsyncWebUtils to WebAsyncUtils.
This commit is contained in:
@@ -52,7 +52,8 @@ public interface AsyncHandlerInterceptor extends HandlerInterceptor {
|
||||
*
|
||||
* @param request the current request
|
||||
* @param response the current response
|
||||
* @param handler handler that started async execution, for type and/or instance examination
|
||||
*/
|
||||
void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response);
|
||||
void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler);
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
import org.springframework.web.context.request.async.WebAsyncManager;
|
||||
import org.springframework.web.context.request.async.AsyncWebUtils;
|
||||
import org.springframework.web.context.request.async.WebAsyncUtils;
|
||||
import org.springframework.web.multipart.MultipartException;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.multipart.MultipartResolver;
|
||||
@@ -819,7 +819,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
String requestUri = urlPathHelper.getRequestUri(request);
|
||||
String resumed = AsyncWebUtils.getAsyncManager(request).hasConcurrentResult() ? " resumed" : "";
|
||||
String resumed = WebAsyncUtils.getAsyncManager(request).hasConcurrentResult() ? " resumed" : "";
|
||||
logger.debug("DispatcherServlet with name '" + getServletName() + "'" + resumed +
|
||||
" processing " + request.getMethod() + " request for [" + requestUri + "]");
|
||||
}
|
||||
@@ -856,7 +856,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||
doDispatch(request, response);
|
||||
}
|
||||
finally {
|
||||
if (AsyncWebUtils.getAsyncManager(request).isConcurrentHandlingStarted()) {
|
||||
if (WebAsyncUtils.getAsyncManager(request).isConcurrentHandlingStarted()) {
|
||||
return;
|
||||
}
|
||||
// Restore the original attribute snapshot, in case of an include.
|
||||
@@ -882,7 +882,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||
HandlerExecutionChain mappedHandler = null;
|
||||
boolean multipartRequestParsed = false;
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(request);
|
||||
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
|
||||
|
||||
try {
|
||||
ModelAndView mv = null;
|
||||
@@ -1001,7 +1001,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||
}
|
||||
}
|
||||
|
||||
if (AsyncWebUtils.getAsyncManager(request).isConcurrentHandlingStarted()) {
|
||||
if (WebAsyncUtils.getAsyncManager(request).isConcurrentHandlingStarted()) {
|
||||
// Concurrent handling started during a forward
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import org.springframework.web.context.request.async.AsyncWebUtils;
|
||||
import org.springframework.web.context.request.async.WebAsyncUtils;
|
||||
import org.springframework.web.context.request.async.WebAsyncManager;
|
||||
import org.springframework.web.context.request.async.WebAsyncManager.WebAsyncThreadInitializer;
|
||||
import org.springframework.web.context.support.ServletRequestHandledEvent;
|
||||
@@ -908,7 +908,7 @@ public abstract class FrameworkServlet extends HttpServletBean {
|
||||
|
||||
initContextHolders(request, localeContext, requestAttributes);
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(request);
|
||||
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
|
||||
asyncManager.registerAsyncThreadInitializer(this.getClass().getName(), createAsyncThreadInitializer(request));
|
||||
|
||||
try {
|
||||
|
||||
@@ -182,8 +182,8 @@ public class HandlerExecutionChain {
|
||||
for (int i = getInterceptors().length - 1; i >= 0; i--) {
|
||||
if (interceptors[i] instanceof AsyncHandlerInterceptor) {
|
||||
try {
|
||||
AsyncHandlerInterceptor asyncInterceptor = (AsyncHandlerInterceptor) interceptors[i];
|
||||
asyncInterceptor.afterConcurrentHandlingStarted(request, response);
|
||||
AsyncHandlerInterceptor asyncInterceptor = (AsyncHandlerInterceptor) this.interceptors[i];
|
||||
asyncInterceptor.afterConcurrentHandlingStarted(request, response, this.handler);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
logger.error("Interceptor [" + interceptors[i] + "] failed in afterConcurrentHandlingStarted", ex);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class WebRequestHandlerInterceptorAdapter implements AsyncHandlerIntercep
|
||||
this.requestInterceptor.afterCompletion(new DispatcherServletWebRequest(request, response), ex);
|
||||
}
|
||||
|
||||
public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response) {
|
||||
public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
if (this.requestInterceptor instanceof AsyncWebRequestInterceptor) {
|
||||
AsyncWebRequestInterceptor asyncInterceptor = (AsyncWebRequestInterceptor) this.requestInterceptor;
|
||||
DispatcherServletWebRequest webRequest = new DispatcherServletWebRequest(request, response);
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.context.request.async.AsyncTask;
|
||||
import org.springframework.web.context.request.async.AsyncWebUtils;
|
||||
import org.springframework.web.context.request.async.WebAsyncUtils;
|
||||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class AsyncTaskMethodReturnValueHandler implements HandlerMethodReturnVal
|
||||
|
||||
AsyncTask asyncTask = (AsyncTask) returnValue;
|
||||
asyncTask.setBeanFactory(this.beanFactory);
|
||||
AsyncWebUtils.getAsyncManager(webRequest).startCallableProcessing(asyncTask.getCallable(), mavContainer);
|
||||
WebAsyncUtils.getAsyncManager(webRequest).startCallableProcessing(asyncTask.getCallable(), mavContainer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.concurrent.Callable;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.context.request.async.AsyncWebUtils;
|
||||
import org.springframework.web.context.request.async.WebAsyncUtils;
|
||||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class CallableMethodReturnValueHandler implements HandlerMethodReturnValu
|
||||
}
|
||||
|
||||
Callable<?> callable = (Callable<?>) returnValue;
|
||||
AsyncWebUtils.getAsyncManager(webRequest).startCallableProcessing(callable, mavContainer);
|
||||
WebAsyncUtils.getAsyncManager(webRequest).startCallableProcessing(callable, mavContainer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.context.request.async.AsyncWebUtils;
|
||||
import org.springframework.web.context.request.async.WebAsyncUtils;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
@@ -45,7 +45,7 @@ public class DeferredResultMethodReturnValueHandler implements HandlerMethodRetu
|
||||
}
|
||||
|
||||
DeferredResult<?> deferredResult = (DeferredResult<?>) returnValue;
|
||||
AsyncWebUtils.getAsyncManager(webRequest).startDeferredResultProcessing(deferredResult, mavContainer);
|
||||
WebAsyncUtils.getAsyncManager(webRequest).startDeferredResultProcessing(deferredResult, mavContainer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ import org.springframework.web.context.request.ServletWebRequest;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
import org.springframework.web.context.request.async.AsyncTask;
|
||||
import org.springframework.web.context.request.async.AsyncWebRequest;
|
||||
import org.springframework.web.context.request.async.AsyncWebUtils;
|
||||
import org.springframework.web.context.request.async.WebAsyncUtils;
|
||||
import org.springframework.web.context.request.async.WebAsyncManager;
|
||||
import org.springframework.web.method.ControllerAdviceBean;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
@@ -696,10 +696,10 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter i
|
||||
modelFactory.initModel(webRequest, mavContainer, requestMappingMethod);
|
||||
mavContainer.setIgnoreDefaultModelOnRedirect(this.ignoreDefaultModelOnRedirect);
|
||||
|
||||
AsyncWebRequest asyncWebRequest = AsyncWebUtils.createAsyncWebRequest(request, response);
|
||||
AsyncWebRequest asyncWebRequest = WebAsyncUtils.createAsyncWebRequest(request, response);
|
||||
asyncWebRequest.setTimeout(this.asyncRequestTimeout);
|
||||
|
||||
final WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(request);
|
||||
final WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
|
||||
asyncManager.setTaskExecutor(this.taskExecutor);
|
||||
asyncManager.setAsyncWebRequest(asyncWebRequest);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user