From 157a1d6ee22567fb5915d940605615405164fde3 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Wed, 28 Nov 2012 10:45:45 -0600 Subject: [PATCH] Rename MvcAsyncTask to WebAsyncTask The name MvcAsyncTask is misleading because the class is part of Spring Web as apposed to Spring MVC. This is also inconsistent with the other async classes which use Web instead of Mvc. This commit changes MvcAsyncTask to WebAsyncTask making it more consistent with the jar it is found in and the other async classes. Issue: SPR-10051 --- .../servlet/result/RequestResultMatchers.java | 4 ++-- .../request/async/WebAsyncManager.java | 18 +++++++-------- .../{MvcAsyncTask.java => WebAsyncTask.java} | 22 +++++++++---------- .../request/async/WebAsyncManagerTests.java | 2 +- .../async/WebAsyncManagerTimeoutTests.java | 6 ++--- .../annotation/AsyncSupportConfigurer.java | 4 ++-- .../AsyncTaskMethodReturnValueHandler.java | 12 +++++----- .../RequestMappingHandlerAdapter.java | 4 ++-- 8 files changed, 36 insertions(+), 36 deletions(-) rename spring-web/src/main/java/org/springframework/web/context/request/async/{MvcAsyncTask.java => WebAsyncTask.java} (88%) diff --git a/spring-test-mvc/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java b/spring-test-mvc/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java index 9a236a4549c..15990939ee0 100644 --- a/spring-test-mvc/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java +++ b/spring-test-mvc/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java @@ -28,7 +28,7 @@ import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.ResultMatcher; import org.springframework.web.context.request.async.DeferredResult; -import org.springframework.web.context.request.async.MvcAsyncTask; +import org.springframework.web.context.request.async.WebAsyncTask; /** * Factory for assertions on the request. An instance of this class is @@ -96,7 +96,7 @@ public class RequestResultMatchers { /** * Assert the result from asynchronous processing. * This method can be used when a controller method returns {@link Callable} - * or {@link MvcAsyncTask}. The value matched is the value returned from the + * or {@link WebAsyncTask}. The value matched is the value returned from the * {@code Callable} or the exception raised. */ public ResultMatcher asyncResult(final Object expectedResult) { diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java b/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java index 381782153d5..a4f0e00e3a3 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java @@ -256,38 +256,38 @@ public final class WebAsyncManager { @SuppressWarnings({ "rawtypes", "unchecked" }) public void startCallableProcessing(final Callable callable, Object... processingContext) { Assert.notNull(callable, "Callable must not be null"); - startCallableProcessing(new MvcAsyncTask(callable), processingContext); + startCallableProcessing(new WebAsyncTask(callable), processingContext); } /** - * Use the given {@link MvcAsyncTask} to configure the task executor as well as + * Use the given {@link WebAsyncTask} to configure the task executor as well as * the timeout value of the {@code AsyncWebRequest} before delegating to * {@link #startCallableProcessing(Callable, Object...)}. * - * @param mvcAsyncTask an MvcAsyncTask containing the target {@code Callable} + * @param webAsyncTask an WebAsyncTask containing the target {@code Callable} * @param processingContext additional context to save that can be accessed * via {@link #getConcurrentResultContext()} */ - public void startCallableProcessing(final MvcAsyncTask mvcAsyncTask, Object... processingContext) { - Assert.notNull(mvcAsyncTask, "MvcAsyncTask must not be null"); + public void startCallableProcessing(final WebAsyncTask webAsyncTask, Object... processingContext) { + Assert.notNull(webAsyncTask, "WebAsyncTask must not be null"); Assert.state(this.asyncWebRequest != null, "AsyncWebRequest must not be null"); - Long timeout = mvcAsyncTask.getTimeout(); + Long timeout = webAsyncTask.getTimeout(); if (timeout != null) { this.asyncWebRequest.setTimeout(timeout); } - AsyncTaskExecutor executor = mvcAsyncTask.getExecutor(); + AsyncTaskExecutor executor = webAsyncTask.getExecutor(); if (executor != null) { this.taskExecutor = executor; } List interceptors = new ArrayList(); - interceptors.add(mvcAsyncTask.getInterceptor()); + interceptors.add(webAsyncTask.getInterceptor()); interceptors.addAll(this.callableInterceptors.values()); interceptors.add(timeoutCallableInterceptor); - final Callable callable = mvcAsyncTask.getCallable(); + final Callable callable = webAsyncTask.getCallable(); final CallableInterceptorChain interceptorChain = new CallableInterceptorChain(interceptors); this.asyncWebRequest.addTimeoutHandler(new Runnable() { diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/MvcAsyncTask.java b/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncTask.java similarity index 88% rename from spring-web/src/main/java/org/springframework/web/context/request/async/MvcAsyncTask.java rename to spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncTask.java index a79e629185e..15cfdc96eeb 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/MvcAsyncTask.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncTask.java @@ -28,7 +28,7 @@ import org.springframework.web.context.request.NativeWebRequest; * @author Rossen Stoyanchev * @since 3.2 */ -public class MvcAsyncTask { +public class WebAsyncTask { private final Callable callable; @@ -46,43 +46,43 @@ public class MvcAsyncTask { /** - * Create an {@code MvcAsyncTask} wrapping the given {@link Callable}. + * Create an {@code WebAsyncTask} wrapping the given {@link Callable}. * @param callable the callable for concurrent handling */ - public MvcAsyncTask(Callable callable) { + public WebAsyncTask(Callable callable) { this(null, null, null, callable); } /** - * Create an {@code MvcAsyncTask} with a timeout value and a {@link Callable}. + * Create an {@code WebAsyncTask} with a timeout value and a {@link Callable}. * @param timeout timeout value in milliseconds * @param callable the callable for concurrent handling */ - public MvcAsyncTask(long timeout, Callable callable) { + public WebAsyncTask(long timeout, Callable callable) { this(timeout, null, null, callable); } /** - * Create an {@code MvcAsyncTask} with a timeout value, an executor name, and a {@link Callable}. + * Create an {@code WebAsyncTask} with a timeout value, an executor name, and a {@link Callable}. * @param timeout timeout value in milliseconds; ignored if {@code null} * @param callable the callable for concurrent handling */ - public MvcAsyncTask(Long timeout, String executorName, Callable callable) { + public WebAsyncTask(Long timeout, String executorName, Callable callable) { this(timeout, null, executorName, callable); Assert.notNull(executor, "Executor name must not be null"); } /** - * Create an {@code MvcAsyncTask} with a timeout value, an executor instance, and a Callable. + * Create an {@code WebAsyncTask} with a timeout value, an executor instance, and a Callable. * @param timeout timeout value in milliseconds; ignored if {@code null} * @param callable the callable for concurrent handling */ - public MvcAsyncTask(Long timeout, AsyncTaskExecutor executor, Callable callable) { + public WebAsyncTask(Long timeout, AsyncTaskExecutor executor, Callable callable) { this(timeout, executor, null, callable); Assert.notNull(executor, "Executor must not be null"); } - private MvcAsyncTask(Long timeout, AsyncTaskExecutor executor, String executorName, Callable callable) { + private WebAsyncTask(Long timeout, AsyncTaskExecutor executor, String executorName, Callable callable) { Assert.notNull(callable, "Callable must not be null"); this.callable = callable; this.timeout = timeout; @@ -123,7 +123,7 @@ public class MvcAsyncTask { /** * A {@link BeanFactory} to use to resolve an executor name. Applications are - * not expected to have to set this property when {@code MvcAsyncTask} is used in a + * not expected to have to set this property when {@code WebAsyncTask} is used in a * Spring MVC controller. */ public void setBeanFactory(BeanFactory beanFactory) { diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java index 11891cfa014..a8436b651b0 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java @@ -244,7 +244,7 @@ public class WebAsyncManagerTests { replay(this.asyncWebRequest); @SuppressWarnings("unchecked") - MvcAsyncTask asyncTask = new MvcAsyncTask(1000L, executor, createMock(Callable.class)); + WebAsyncTask asyncTask = new WebAsyncTask(1000L, executor, createMock(Callable.class)); this.asyncManager.startCallableProcessing(asyncTask); verify(executor, this.asyncWebRequest); diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java index aac5f5f7ddd..0948d831c4b 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java @@ -101,14 +101,14 @@ public class WebAsyncManagerTimeoutTests { public void startCallableProcessingTimeoutAndResumeThroughCallback() throws Exception { StubCallable callable = new StubCallable(); - MvcAsyncTask mvcAsyncTask = new MvcAsyncTask(callable); - mvcAsyncTask.onTimeout(new Callable() { + WebAsyncTask webAsyncTask = new WebAsyncTask(callable); + webAsyncTask.onTimeout(new Callable() { public Object call() throws Exception { return 7; } }); - this.asyncManager.startCallableProcessing(mvcAsyncTask); + this.asyncManager.startCallableProcessing(webAsyncTask); this.asyncWebRequest.onTimeout(ASYNC_EVENT); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer.java index 271c5b2c390..07d2b1a87e5 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer.java @@ -23,7 +23,7 @@ import java.util.concurrent.Callable; import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.util.Assert; -import org.springframework.web.context.request.async.MvcAsyncTask; +import org.springframework.web.context.request.async.WebAsyncTask; import org.springframework.web.context.request.async.CallableProcessingInterceptor; import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResultProcessingInterceptor; @@ -50,7 +50,7 @@ public class AsyncSupportConfigurer { /** * Set the default {@link AsyncTaskExecutor} to use when a controller method * returns a {@link Callable}. Controller methods can override this default on - * a per-request basis by returning an {@link MvcAsyncTask}. + * a per-request basis by returning an {@link WebAsyncTask}. * *

By default a {@link SimpleAsyncTaskExecutor} instance is used and it's * highly recommended to change that default in production since the simple diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AsyncTaskMethodReturnValueHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AsyncTaskMethodReturnValueHandler.java index 3855fe388c1..98130ad84ea 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AsyncTaskMethodReturnValueHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AsyncTaskMethodReturnValueHandler.java @@ -19,13 +19,13 @@ package org.springframework.web.servlet.mvc.method.annotation; 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.MvcAsyncTask; +import org.springframework.web.context.request.async.WebAsyncTask; import org.springframework.web.context.request.async.WebAsyncUtils; import org.springframework.web.method.support.HandlerMethodReturnValueHandler; import org.springframework.web.method.support.ModelAndViewContainer; /** - * Handles return values of type {@link MvcAsyncTask}. + * Handles return values of type {@link WebAsyncTask}. * * @author Rossen Stoyanchev * @since 3.2 @@ -41,7 +41,7 @@ public class AsyncTaskMethodReturnValueHandler implements HandlerMethodReturnVal public boolean supportsReturnType(MethodParameter returnType) { Class paramType = returnType.getParameterType(); - return MvcAsyncTask.class.isAssignableFrom(paramType); + return WebAsyncTask.class.isAssignableFrom(paramType); } public void handleReturnValue(Object returnValue, @@ -53,9 +53,9 @@ public class AsyncTaskMethodReturnValueHandler implements HandlerMethodReturnVal return; } - MvcAsyncTask mvcAsyncTask = (MvcAsyncTask) returnValue; - mvcAsyncTask.setBeanFactory(this.beanFactory); - WebAsyncUtils.getAsyncManager(webRequest).startCallableProcessing(mvcAsyncTask, mavContainer); + WebAsyncTask webAsyncTask = (WebAsyncTask) returnValue; + webAsyncTask.setBeanFactory(this.beanFactory); + WebAsyncUtils.getAsyncManager(webRequest).startCallableProcessing(webAsyncTask, mavContainer); } } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java index ad9279328eb..6d2597e5b61 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java @@ -63,7 +63,7 @@ import org.springframework.web.bind.support.WebDataBinderFactory; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.context.request.WebRequest; -import org.springframework.web.context.request.async.MvcAsyncTask; +import org.springframework.web.context.request.async.WebAsyncTask; import org.springframework.web.context.request.async.AsyncWebRequest; import org.springframework.web.context.request.async.CallableProcessingInterceptor; import org.springframework.web.context.request.async.DeferredResultProcessingInterceptor; @@ -348,7 +348,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter i /** * Set the default {@link AsyncTaskExecutor} to use when a controller method * return a {@link Callable}. Controller methods can override this default on - * a per-request basis by returning an {@link MvcAsyncTask}. + * a per-request basis by returning an {@link WebAsyncTask}. *

By default a {@link SimpleAsyncTaskExecutor} instance is used. * It's recommended to change that default in production as the simple executor * does not re-use threads.