Skip to content

Commit 157a1d6

Browse files
rwinchrstoyanchev
authored andcommitted
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
1 parent ce7fa8a commit 157a1d6

File tree

8 files changed

+36
-36
lines changed

8 files changed

+36
-36
lines changed

spring-test-mvc/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.springframework.test.web.servlet.MvcResult;
2929
import org.springframework.test.web.servlet.ResultMatcher;
3030
import org.springframework.web.context.request.async.DeferredResult;
31-
import org.springframework.web.context.request.async.MvcAsyncTask;
31+
import org.springframework.web.context.request.async.WebAsyncTask;
3232

3333
/**
3434
* Factory for assertions on the request. An instance of this class is
@@ -96,7 +96,7 @@ public void match(MvcResult result) {
9696
/**
9797
* Assert the result from asynchronous processing.
9898
* This method can be used when a controller method returns {@link Callable}
99-
* or {@link MvcAsyncTask}. The value matched is the value returned from the
99+
* or {@link WebAsyncTask}. The value matched is the value returned from the
100100
* {@code Callable} or the exception raised.
101101
*/
102102
public <T> ResultMatcher asyncResult(final Object expectedResult) {

spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,38 +256,38 @@ public void clearConcurrentResult() {
256256
@SuppressWarnings({ "rawtypes", "unchecked" })
257257
public void startCallableProcessing(final Callable<?> callable, Object... processingContext) {
258258
Assert.notNull(callable, "Callable must not be null");
259-
startCallableProcessing(new MvcAsyncTask(callable), processingContext);
259+
startCallableProcessing(new WebAsyncTask(callable), processingContext);
260260
}
261261

262262
/**
263-
* Use the given {@link MvcAsyncTask} to configure the task executor as well as
263+
* Use the given {@link WebAsyncTask} to configure the task executor as well as
264264
* the timeout value of the {@code AsyncWebRequest} before delegating to
265265
* {@link #startCallableProcessing(Callable, Object...)}.
266266
*
267-
* @param mvcAsyncTask an MvcAsyncTask containing the target {@code Callable}
267+
* @param webAsyncTask an WebAsyncTask containing the target {@code Callable}
268268
* @param processingContext additional context to save that can be accessed
269269
* via {@link #getConcurrentResultContext()}
270270
*/
271-
public void startCallableProcessing(final MvcAsyncTask<?> mvcAsyncTask, Object... processingContext) {
272-
Assert.notNull(mvcAsyncTask, "MvcAsyncTask must not be null");
271+
public void startCallableProcessing(final WebAsyncTask<?> webAsyncTask, Object... processingContext) {
272+
Assert.notNull(webAsyncTask, "WebAsyncTask must not be null");
273273
Assert.state(this.asyncWebRequest != null, "AsyncWebRequest must not be null");
274274

275-
Long timeout = mvcAsyncTask.getTimeout();
275+
Long timeout = webAsyncTask.getTimeout();
276276
if (timeout != null) {
277277
this.asyncWebRequest.setTimeout(timeout);
278278
}
279279

280-
AsyncTaskExecutor executor = mvcAsyncTask.getExecutor();
280+
AsyncTaskExecutor executor = webAsyncTask.getExecutor();
281281
if (executor != null) {
282282
this.taskExecutor = executor;
283283
}
284284

285285
List<CallableProcessingInterceptor> interceptors = new ArrayList<CallableProcessingInterceptor>();
286-
interceptors.add(mvcAsyncTask.getInterceptor());
286+
interceptors.add(webAsyncTask.getInterceptor());
287287
interceptors.addAll(this.callableInterceptors.values());
288288
interceptors.add(timeoutCallableInterceptor);
289289

290-
final Callable<?> callable = mvcAsyncTask.getCallable();
290+
final Callable<?> callable = webAsyncTask.getCallable();
291291
final CallableInterceptorChain interceptorChain = new CallableInterceptorChain(interceptors);
292292

293293
this.asyncWebRequest.addTimeoutHandler(new Runnable() {
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* @author Rossen Stoyanchev
2929
* @since 3.2
3030
*/
31-
public class MvcAsyncTask<V> {
31+
public class WebAsyncTask<V> {
3232

3333
private final Callable<V> callable;
3434

@@ -46,43 +46,43 @@ public class MvcAsyncTask<V> {
4646

4747

4848
/**
49-
* Create an {@code MvcAsyncTask} wrapping the given {@link Callable}.
49+
* Create an {@code WebAsyncTask} wrapping the given {@link Callable}.
5050
* @param callable the callable for concurrent handling
5151
*/
52-
public MvcAsyncTask(Callable<V> callable) {
52+
public WebAsyncTask(Callable<V> callable) {
5353
this(null, null, null, callable);
5454
}
5555

5656
/**
57-
* Create an {@code MvcAsyncTask} with a timeout value and a {@link Callable}.
57+
* Create an {@code WebAsyncTask} with a timeout value and a {@link Callable}.
5858
* @param timeout timeout value in milliseconds
5959
* @param callable the callable for concurrent handling
6060
*/
61-
public MvcAsyncTask(long timeout, Callable<V> callable) {
61+
public WebAsyncTask(long timeout, Callable<V> callable) {
6262
this(timeout, null, null, callable);
6363
}
6464

6565
/**
66-
* Create an {@code MvcAsyncTask} with a timeout value, an executor name, and a {@link Callable}.
66+
* Create an {@code WebAsyncTask} with a timeout value, an executor name, and a {@link Callable}.
6767
* @param timeout timeout value in milliseconds; ignored if {@code null}
6868
* @param callable the callable for concurrent handling
6969
*/
70-
public MvcAsyncTask(Long timeout, String executorName, Callable<V> callable) {
70+
public WebAsyncTask(Long timeout, String executorName, Callable<V> callable) {
7171
this(timeout, null, executorName, callable);
7272
Assert.notNull(executor, "Executor name must not be null");
7373
}
7474

7575
/**
76-
* Create an {@code MvcAsyncTask} with a timeout value, an executor instance, and a Callable.
76+
* Create an {@code WebAsyncTask} with a timeout value, an executor instance, and a Callable.
7777
* @param timeout timeout value in milliseconds; ignored if {@code null}
7878
* @param callable the callable for concurrent handling
7979
*/
80-
public MvcAsyncTask(Long timeout, AsyncTaskExecutor executor, Callable<V> callable) {
80+
public WebAsyncTask(Long timeout, AsyncTaskExecutor executor, Callable<V> callable) {
8181
this(timeout, executor, null, callable);
8282
Assert.notNull(executor, "Executor must not be null");
8383
}
8484

85-
private MvcAsyncTask(Long timeout, AsyncTaskExecutor executor, String executorName, Callable<V> callable) {
85+
private WebAsyncTask(Long timeout, AsyncTaskExecutor executor, String executorName, Callable<V> callable) {
8686
Assert.notNull(callable, "Callable must not be null");
8787
this.callable = callable;
8888
this.timeout = timeout;
@@ -123,7 +123,7 @@ else if (this.executorName != null) {
123123

124124
/**
125125
* A {@link BeanFactory} to use to resolve an executor name. Applications are
126-
* not expected to have to set this property when {@code MvcAsyncTask} is used in a
126+
* not expected to have to set this property when {@code WebAsyncTask} is used in a
127127
* Spring MVC controller.
128128
*/
129129
public void setBeanFactory(BeanFactory beanFactory) {

spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public void startCallableProcessingWithAsyncTask() {
244244
replay(this.asyncWebRequest);
245245

246246
@SuppressWarnings("unchecked")
247-
MvcAsyncTask<Object> asyncTask = new MvcAsyncTask<Object>(1000L, executor, createMock(Callable.class));
247+
WebAsyncTask<Object> asyncTask = new WebAsyncTask<Object>(1000L, executor, createMock(Callable.class));
248248
this.asyncManager.startCallableProcessing(asyncTask);
249249

250250
verify(executor, this.asyncWebRequest);

spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ public void startCallableProcessingTimeoutAndComplete() throws Exception {
101101
public void startCallableProcessingTimeoutAndResumeThroughCallback() throws Exception {
102102

103103
StubCallable callable = new StubCallable();
104-
MvcAsyncTask<Object> mvcAsyncTask = new MvcAsyncTask<Object>(callable);
105-
mvcAsyncTask.onTimeout(new Callable<Object>() {
104+
WebAsyncTask<Object> webAsyncTask = new WebAsyncTask<Object>(callable);
105+
webAsyncTask.onTimeout(new Callable<Object>() {
106106
public Object call() throws Exception {
107107
return 7;
108108
}
109109
});
110110

111-
this.asyncManager.startCallableProcessing(mvcAsyncTask);
111+
this.asyncManager.startCallableProcessing(webAsyncTask);
112112

113113
this.asyncWebRequest.onTimeout(ASYNC_EVENT);
114114

spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.springframework.core.task.AsyncTaskExecutor;
2424
import org.springframework.core.task.SimpleAsyncTaskExecutor;
2525
import org.springframework.util.Assert;
26-
import org.springframework.web.context.request.async.MvcAsyncTask;
26+
import org.springframework.web.context.request.async.WebAsyncTask;
2727
import org.springframework.web.context.request.async.CallableProcessingInterceptor;
2828
import org.springframework.web.context.request.async.DeferredResult;
2929
import org.springframework.web.context.request.async.DeferredResultProcessingInterceptor;
@@ -50,7 +50,7 @@ public class AsyncSupportConfigurer {
5050
/**
5151
* Set the default {@link AsyncTaskExecutor} to use when a controller method
5252
* returns a {@link Callable}. Controller methods can override this default on
53-
* a per-request basis by returning an {@link MvcAsyncTask}.
53+
* a per-request basis by returning an {@link WebAsyncTask}.
5454
*
5555
* <p>By default a {@link SimpleAsyncTaskExecutor} instance is used and it's
5656
* highly recommended to change that default in production since the simple

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AsyncTaskMethodReturnValueHandler.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
import org.springframework.beans.factory.BeanFactory;
2020
import org.springframework.core.MethodParameter;
2121
import org.springframework.web.context.request.NativeWebRequest;
22-
import org.springframework.web.context.request.async.MvcAsyncTask;
22+
import org.springframework.web.context.request.async.WebAsyncTask;
2323
import org.springframework.web.context.request.async.WebAsyncUtils;
2424
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
2525
import org.springframework.web.method.support.ModelAndViewContainer;
2626

2727
/**
28-
* Handles return values of type {@link MvcAsyncTask}.
28+
* Handles return values of type {@link WebAsyncTask}.
2929
*
3030
* @author Rossen Stoyanchev
3131
* @since 3.2
@@ -41,7 +41,7 @@ public AsyncTaskMethodReturnValueHandler(BeanFactory beanFactory) {
4141

4242
public boolean supportsReturnType(MethodParameter returnType) {
4343
Class<?> paramType = returnType.getParameterType();
44-
return MvcAsyncTask.class.isAssignableFrom(paramType);
44+
return WebAsyncTask.class.isAssignableFrom(paramType);
4545
}
4646

4747
public void handleReturnValue(Object returnValue,
@@ -53,9 +53,9 @@ public void handleReturnValue(Object returnValue,
5353
return;
5454
}
5555

56-
MvcAsyncTask<?> mvcAsyncTask = (MvcAsyncTask<?>) returnValue;
57-
mvcAsyncTask.setBeanFactory(this.beanFactory);
58-
WebAsyncUtils.getAsyncManager(webRequest).startCallableProcessing(mvcAsyncTask, mavContainer);
56+
WebAsyncTask<?> webAsyncTask = (WebAsyncTask<?>) returnValue;
57+
webAsyncTask.setBeanFactory(this.beanFactory);
58+
WebAsyncUtils.getAsyncManager(webRequest).startCallableProcessing(webAsyncTask, mavContainer);
5959
}
6060

6161
}

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
import org.springframework.web.context.request.NativeWebRequest;
6464
import org.springframework.web.context.request.ServletWebRequest;
6565
import org.springframework.web.context.request.WebRequest;
66-
import org.springframework.web.context.request.async.MvcAsyncTask;
66+
import org.springframework.web.context.request.async.WebAsyncTask;
6767
import org.springframework.web.context.request.async.AsyncWebRequest;
6868
import org.springframework.web.context.request.async.CallableProcessingInterceptor;
6969
import org.springframework.web.context.request.async.DeferredResultProcessingInterceptor;
@@ -348,7 +348,7 @@ public WebBindingInitializer getWebBindingInitializer() {
348348
/**
349349
* Set the default {@link AsyncTaskExecutor} to use when a controller method
350350
* return a {@link Callable}. Controller methods can override this default on
351-
* a per-request basis by returning an {@link MvcAsyncTask}.
351+
* a per-request basis by returning an {@link WebAsyncTask}.
352352
* <p>By default a {@link SimpleAsyncTaskExecutor} instance is used.
353353
* It's recommended to change that default in production as the simple executor
354354
* does not re-use threads.

0 commit comments

Comments
 (0)