Polish async support
Added handler argument to the signature of AsyncHandlerInterceptor.afterConcurrentHandlingStarted(..). Renamed AsyncWebUtils to WebAsyncUtils.
This commit is contained in:
parent
ccd7b10237
commit
97f97c4e9f
|
@ -32,7 +32,7 @@ import org.springframework.orm.hibernate3.SessionHolder;
|
|||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
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.WebApplicationContextUtils;
|
||||
|
@ -184,7 +184,7 @@ public class OpenSessionInViewFilter extends OncePerRequestFilter {
|
|||
SessionFactory sessionFactory = lookupSessionFactory(request);
|
||||
boolean participate = false;
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(request);
|
||||
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
|
||||
boolean isFirstRequest = !isAsyncDispatch(request);
|
||||
String key = getAlreadyFilteredAttributeName();
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
|||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.context.request.AsyncWebRequestInterceptor;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
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;
|
||||
|
||||
|
@ -143,7 +143,7 @@ public class OpenSessionInViewInterceptor extends HibernateAccessor implements A
|
|||
*/
|
||||
public void preHandle(WebRequest request) throws DataAccessException {
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(request);
|
||||
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
|
||||
String participateAttributeName = getParticipateAttributeName();
|
||||
|
||||
if (asyncManager.hasConcurrentResult()) {
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.springframework.orm.hibernate4.SessionFactoryUtils;
|
|||
import org.springframework.orm.hibernate4.SessionHolder;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
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.WebApplicationContextUtils;
|
||||
|
@ -117,7 +117,7 @@ public class OpenSessionInViewFilter extends OncePerRequestFilter {
|
|||
SessionFactory sessionFactory = lookupSessionFactory(request);
|
||||
boolean participate = false;
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(request);
|
||||
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
|
||||
boolean isFirstRequest = !isAsyncDispatch(request);
|
||||
String key = getAlreadyFilteredAttributeName();
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
|||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.context.request.AsyncWebRequestInterceptor;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
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;
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class OpenSessionInViewInterceptor implements AsyncWebRequestInterceptor
|
|||
|
||||
String participateAttributeName = getParticipateAttributeName();
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(request);
|
||||
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
|
||||
if (asyncManager.hasConcurrentResult()) {
|
||||
if (asyncManager.initializeAsyncThread(participateAttributeName)) {
|
||||
return;
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.springframework.orm.jpa.EntityManagerHolder;
|
|||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
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.WebApplicationContextUtils;
|
||||
|
@ -141,7 +141,7 @@ public class OpenEntityManagerInViewFilter extends OncePerRequestFilter {
|
|||
EntityManagerFactory emf = lookupEntityManagerFactory(request);
|
||||
boolean participate = false;
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(request);
|
||||
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
|
||||
boolean isFirstRequest = !isAsyncDispatch(request);
|
||||
String key = getAlreadyFilteredAttributeName();
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
|||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.context.request.AsyncWebRequestInterceptor;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
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;
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class OpenEntityManagerInViewInterceptor extends EntityManagerFactoryAcce
|
|||
|
||||
String participateAttributeName = getParticipateAttributeName();
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(request);
|
||||
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
|
||||
if (asyncManager.hasConcurrentResult()) {
|
||||
if (asyncManager.initializeAsyncThread(participateAttributeName)) {
|
||||
return;
|
||||
|
|
|
@ -63,7 +63,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
|||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
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.context.support.StaticWebApplicationContext;
|
||||
|
||||
|
@ -180,7 +180,7 @@ public class OpenSessionInViewTests {
|
|||
asyncWebRequest.startAsync();
|
||||
replay(asyncWebRequest);
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(this.request);
|
||||
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(this.request);
|
||||
asyncManager.setAsyncWebRequest(asyncWebRequest);
|
||||
|
||||
asyncManager.startCallableProcessing(new Callable<String>() {
|
||||
|
@ -499,7 +499,7 @@ public class OpenSessionInViewTests {
|
|||
expect(asyncWebRequest.isDispatched()).andReturn(false).anyTimes();
|
||||
replay(asyncWebRequest);
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(this.request);
|
||||
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(this.request);
|
||||
asyncManager.setAsyncWebRequest(asyncWebRequest);
|
||||
asyncManager.startCallableProcessing(new Callable<String>() {
|
||||
public String call() throws Exception {
|
||||
|
|
|
@ -48,7 +48,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
|||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
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.context.support.StaticWebApplicationContext;
|
||||
|
||||
|
@ -157,7 +157,7 @@ public class OpenEntityManagerInViewTests extends TestCase {
|
|||
asyncWebRequest.startAsync();
|
||||
replay(asyncWebRequest);
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(webRequest);
|
||||
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(webRequest);
|
||||
asyncManager.setAsyncWebRequest(asyncWebRequest);
|
||||
asyncManager.startCallableProcessing(new Callable<String>() {
|
||||
public String call() throws Exception {
|
||||
|
@ -351,7 +351,7 @@ public class OpenEntityManagerInViewTests extends TestCase {
|
|||
expect(asyncWebRequest.isDispatched()).andReturn(false).anyTimes();
|
||||
replay(asyncWebRequest);
|
||||
|
||||
WebAsyncManager asyncManager = AsyncWebUtils.getAsyncManager(request);
|
||||
WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
|
||||
asyncManager.setAsyncWebRequest(asyncWebRequest);
|
||||
asyncManager.startCallableProcessing(new Callable<String>() {
|
||||
public String call() throws Exception {
|
||||
|
|
|
@ -80,8 +80,8 @@ public final class WebAsyncManager {
|
|||
|
||||
/**
|
||||
* Package private constructor.
|
||||
* @see AsyncWebUtils#getAsyncManager(javax.servlet.ServletRequest)
|
||||
* @see AsyncWebUtils#getAsyncManager(org.springframework.web.context.request.WebRequest)
|
||||
* @see WebAsyncUtils#getAsyncManager(javax.servlet.ServletRequest)
|
||||
* @see WebAsyncUtils#getAsyncManager(org.springframework.web.context.request.WebRequest)
|
||||
*/
|
||||
WebAsyncManager() {
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public final class WebAsyncManager {
|
|||
this.asyncWebRequest = asyncWebRequest;
|
||||
this.asyncWebRequest.addCompletionHandler(new Runnable() {
|
||||
public void run() {
|
||||
asyncWebRequest.removeAttribute(AsyncWebUtils.WEB_ASYNC_MANAGER_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
|
||||
asyncWebRequest.removeAttribute(WebAsyncUtils.WEB_ASYNC_MANAGER_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.springframework.web.context.request.WebRequest;
|
|||
* @author Rossen Stoyanchev
|
||||
* @since 3.2
|
||||
*/
|
||||
public abstract class AsyncWebUtils {
|
||||
public abstract class WebAsyncUtils {
|
||||
|
||||
public static final String WEB_ASYNC_MANAGER_ATTRIBUTE = WebAsyncManager.class.getName() + ".WEB_ASYNC_MANAGER";
|
||||
|
||||
|
@ -80,7 +80,7 @@ public abstract class AsyncWebUtils {
|
|||
private static AsyncWebRequest createStandardServletAsyncWebRequest(HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
String className = "org.springframework.web.context.request.async.StandardServletAsyncWebRequest";
|
||||
Class<?> clazz = ClassUtils.forName(className, AsyncWebUtils.class.getClassLoader());
|
||||
Class<?> clazz = ClassUtils.forName(className, WebAsyncUtils.class.getClassLoader());
|
||||
Constructor<?> constructor = clazz.getConstructor(HttpServletRequest.class, HttpServletResponse.class);
|
||||
return (AsyncWebRequest) BeanUtils.instantiateClass(constructor, request, response);
|
||||
}
|
|
@ -25,7 +25,7 @@ import javax.servlet.ServletResponse;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.web.context.request.async.AsyncWebUtils;
|
||||
import org.springframework.web.context.request.async.WebAsyncUtils;
|
||||
|
||||
/**
|
||||
* Filter base class that guarantees to be just executed once per request,
|
||||
|
@ -159,7 +159,7 @@ public abstract class OncePerRequestFilter extends GenericFilterBean {
|
|||
* @see org.springframework.web.context.request.async.WebAsyncManager
|
||||
*/
|
||||
protected final boolean isAsyncDispatch(HttpServletRequest request) {
|
||||
return AsyncWebUtils.getAsyncManager(request).hasConcurrentResult();
|
||||
return WebAsyncUtils.getAsyncManager(request).hasConcurrentResult();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,7 +175,7 @@ public abstract class OncePerRequestFilter extends GenericFilterBean {
|
|||
* @see org.springframework.web.context.request.async.WebAsyncManager
|
||||
*/
|
||||
protected final boolean isLastRequestThread(HttpServletRequest request) {
|
||||
return (!AsyncWebUtils.getAsyncManager(request).isConcurrentHandlingStarted());
|
||||
return (!WebAsyncUtils.getAsyncManager(request).isConcurrentHandlingStarted());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -51,7 +51,7 @@ public class WebAsyncManagerTests {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.asyncManager = AsyncWebUtils.getAsyncManager(new MockHttpServletRequest());
|
||||
this.asyncManager = WebAsyncUtils.getAsyncManager(new MockHttpServletRequest());
|
||||
this.asyncManager.setTaskExecutor(new SyncTaskExecutor());
|
||||
|
||||
this.asyncWebRequest = createStrictMock(AsyncWebRequest.class);
|
||||
|
@ -142,7 +142,7 @@ public class WebAsyncManagerTests {
|
|||
|
||||
@Test
|
||||
public void startCallableProcessingNullRequest() {
|
||||
WebAsyncManager manager = AsyncWebUtils.getAsyncManager(new MockHttpServletRequest());
|
||||
WebAsyncManager manager = WebAsyncUtils.getAsyncManager(new MockHttpServletRequest());
|
||||
try {
|
||||
manager.startCallableProcessing(new Callable<Object>() {
|
||||
public Object call() throws Exception {
|
||||
|
|
|
@ -33,7 +33,7 @@ import junit.framework.TestCase;
|
|||
import org.springframework.mock.web.MockFilterConfig;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
import org.springframework.web.context.request.async.AsyncWebUtils;
|
||||
import org.springframework.web.context.request.async.WebAsyncUtils;
|
||||
|
||||
/**
|
||||
* @author Rick Evans
|
||||
|
@ -176,9 +176,9 @@ public class CharacterEncodingFilterTests extends TestCase {
|
|||
|
||||
|
||||
private void addAsyncManagerExpectations(HttpServletRequest request) {
|
||||
expect(request.getAttribute(AsyncWebUtils.WEB_ASYNC_MANAGER_ATTRIBUTE)).andReturn(null);
|
||||
expect(request.getAttribute(WebAsyncUtils.WEB_ASYNC_MANAGER_ATTRIBUTE)).andReturn(null);
|
||||
expectLastCall().anyTimes();
|
||||
request.setAttribute(same(AsyncWebUtils.WEB_ASYNC_MANAGER_ATTRIBUTE), notNull());
|
||||
request.setAttribute(same(WebAsyncUtils.WEB_ASYNC_MANAGER_ATTRIBUTE), notNull());
|
||||
expectLastCall().anyTimes();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -92,15 +92,13 @@ public class HandlerExecutionChainTests {
|
|||
|
||||
@Test
|
||||
public void successAsyncScenario() throws Exception {
|
||||
ModelAndView mav = new ModelAndView();
|
||||
|
||||
expect(this.interceptor1.preHandle(this.request, this.response, this.handler)).andReturn(true);
|
||||
expect(this.interceptor2.preHandle(this.request, this.response, this.handler)).andReturn(true);
|
||||
expect(this.interceptor3.preHandle(this.request, this.response, this.handler)).andReturn(true);
|
||||
|
||||
this.interceptor1.afterConcurrentHandlingStarted(request, response);
|
||||
this.interceptor2.afterConcurrentHandlingStarted(request, response);
|
||||
this.interceptor3.afterConcurrentHandlingStarted(request, response);
|
||||
this.interceptor1.afterConcurrentHandlingStarted(request, response, this.handler);
|
||||
this.interceptor2.afterConcurrentHandlingStarted(request, response, this.handler);
|
||||
this.interceptor3.afterConcurrentHandlingStarted(request, response, this.handler);
|
||||
|
||||
replay(this.interceptor1, this.interceptor2, this.interceptor3);
|
||||
|
||||
|
|
Loading…
Reference in New Issue