Skip to content

Commit ed14ae6

Browse files
committed
Consistent deprecation of outdated MVC infrastructure classes
Issue: SPR-14128
1 parent 4ea4257 commit ed14ae6

19 files changed

+68
-36
lines changed

spring-web/src/main/java/org/springframework/web/bind/annotation/support/HandlerMethodInvocationException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
* @author Juergen Hoeller
2727
* @since 2.5.6
2828
* @see HandlerMethodInvoker#invokeHandlerMethod
29+
* @deprecated as of 4.3, in favor of the {@code HandlerMethod}-based MVC infrastructure
2930
*/
31+
@Deprecated
3032
@SuppressWarnings("serial")
3133
public class HandlerMethodInvocationException extends NestedRuntimeException {
3234

spring-web/src/main/java/org/springframework/web/bind/annotation/support/HandlerMethodInvoker.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@
9494
* @author Arjen Poutsma
9595
* @since 2.5.2
9696
* @see #invokeHandlerMethod
97+
* @deprecated as of 4.3, in favor of the {@code HandlerMethod}-based MVC infrastructure
9798
*/
99+
@Deprecated
98100
public class HandlerMethodInvoker {
99101

100102
private static final String MODEL_KEY_PREFIX_STALE = SessionAttributeStore.class.getName() + ".STALE.";

spring-web/src/main/java/org/springframework/web/bind/annotation/support/HandlerMethodResolver.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@
4848
* @see org.springframework.web.bind.annotation.InitBinder
4949
* @see org.springframework.web.bind.annotation.ModelAttribute
5050
* @see org.springframework.web.bind.annotation.SessionAttributes
51+
* @deprecated as of 4.3, in favor of the {@code HandlerMethod}-based MVC infrastructure
5152
*/
53+
@Deprecated
5254
public class HandlerMethodResolver {
5355

5456
private final Set<Method> handlerMethods = new LinkedHashSet<Method>();

spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/mvc/annotation/AnnotationMethodHandlerAdapter.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@
7676
import org.springframework.web.bind.annotation.RequestMethod;
7777
import org.springframework.web.bind.annotation.RequestParam;
7878
import org.springframework.web.bind.annotation.SessionAttributes;
79-
import org.springframework.web.bind.annotation.support.HandlerMethodInvoker;
80-
import org.springframework.web.bind.annotation.support.HandlerMethodResolver;
8179
import org.springframework.web.bind.support.DefaultSessionAttributeStore;
8280
import org.springframework.web.bind.support.SessionAttributeStore;
8381
import org.springframework.web.bind.support.WebArgumentResolver;
@@ -434,9 +432,10 @@ protected PortletRequestDataBinder createBinder(PortletRequest request, Object t
434432

435433

436434
/**
437-
* Portlet-specific subclass of {@link HandlerMethodResolver}.
435+
* Portlet-specific subclass of {@code HandlerMethodResolver}.
438436
*/
439-
private static class PortletHandlerMethodResolver extends HandlerMethodResolver {
437+
@SuppressWarnings("deprecation")
438+
private static class PortletHandlerMethodResolver extends org.springframework.web.bind.annotation.support.HandlerMethodResolver {
440439

441440
private final Map<Method, RequestMappingInfo> mappings = new HashMap<Method, RequestMappingInfo>();
442441

@@ -545,11 +544,12 @@ else if (EventRequest.class.isAssignableFrom(argType) || EventResponse.class.isA
545544

546545

547546
/**
548-
* Portlet-specific subclass of {@link HandlerMethodInvoker}.
547+
* Portlet-specific subclass of {@code HandlerMethodInvoker}.
549548
*/
550-
private class PortletHandlerMethodInvoker extends HandlerMethodInvoker {
549+
@SuppressWarnings("deprecation")
550+
private class PortletHandlerMethodInvoker extends org.springframework.web.bind.annotation.support.HandlerMethodInvoker {
551551

552-
public PortletHandlerMethodInvoker(HandlerMethodResolver resolver) {
552+
public PortletHandlerMethodInvoker(org.springframework.web.bind.annotation.support.HandlerMethodResolver resolver) {
553553
super(resolver, webBindingInitializer, sessionAttributeStore,
554554
parameterNameDiscoverer, customArgumentResolvers, null);
555555
}

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@
9696
import org.springframework.web.bind.annotation.ResponseBody;
9797
import org.springframework.web.bind.annotation.ResponseStatus;
9898
import org.springframework.web.bind.annotation.SessionAttributes;
99-
import org.springframework.web.bind.annotation.support.HandlerMethodInvoker;
100-
import org.springframework.web.bind.annotation.support.HandlerMethodResolver;
10199
import org.springframework.web.bind.support.DefaultSessionAttributeStore;
102100
import org.springframework.web.bind.support.SessionAttributeStore;
103101
import org.springframework.web.bind.support.WebArgumentResolver;
@@ -110,9 +108,6 @@
110108
import org.springframework.web.servlet.HandlerMapping;
111109
import org.springframework.web.servlet.ModelAndView;
112110
import org.springframework.web.servlet.View;
113-
import org.springframework.web.servlet.mvc.multiaction.InternalPathMethodNameResolver;
114-
import org.springframework.web.servlet.mvc.multiaction.MethodNameResolver;
115-
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException;
116111
import org.springframework.web.servlet.support.RequestContextUtils;
117112
import org.springframework.web.servlet.support.WebContentGenerator;
118113
import org.springframework.web.util.UrlPathHelper;
@@ -164,7 +159,8 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
164159

165160
private PathMatcher pathMatcher = new AntPathMatcher();
166161

167-
private MethodNameResolver methodNameResolver = new InternalPathMethodNameResolver();
162+
private org.springframework.web.servlet.mvc.multiaction.MethodNameResolver methodNameResolver =
163+
new org.springframework.web.servlet.mvc.multiaction.InternalPathMethodNameResolver();
168164

169165
private WebBindingInitializer webBindingInitializer;
170166

@@ -255,7 +251,7 @@ public void setPathMatcher(PathMatcher pathMatcher) {
255251
* <p>Will only kick in when the handler method cannot be resolved uniquely
256252
* through the annotation metadata already.
257253
*/
258-
public void setMethodNameResolver(MethodNameResolver methodNameResolver) {
254+
public void setMethodNameResolver(org.springframework.web.servlet.mvc.multiaction.MethodNameResolver methodNameResolver) {
259255
this.methodNameResolver = methodNameResolver;
260256
}
261257

@@ -524,9 +520,10 @@ protected HttpOutputMessage createHttpOutputMessage(HttpServletResponse servletR
524520

525521

526522
/**
527-
* Servlet-specific subclass of {@link HandlerMethodResolver}.
523+
* Servlet-specific subclass of {@code HandlerMethodResolver}.
528524
*/
529-
private class ServletHandlerMethodResolver extends HandlerMethodResolver {
525+
@SuppressWarnings("deprecation")
526+
private class ServletHandlerMethodResolver extends org.springframework.web.bind.annotation.support.HandlerMethodResolver {
530527

531528
private final Map<Method, RequestMappingInfo> mappings = new HashMap<Method, RequestMappingInfo>();
532529

@@ -674,7 +671,8 @@ else if (useTypeLevelMapping(request)) {
674671
if (!allowedMethods.isEmpty()) {
675672
throw new HttpRequestMethodNotSupportedException(request.getMethod(), StringUtils.toStringArray(allowedMethods));
676673
}
677-
throw new NoSuchRequestHandlingMethodException(lookupPath, request.getMethod(), request.getParameterMap());
674+
throw new org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException(
675+
lookupPath, request.getMethod(), request.getParameterMap());
678676
}
679677
}
680678

@@ -768,13 +766,14 @@ private void extractHandlerMethodUriTemplates(String mappedPattern, String looku
768766

769767

770768
/**
771-
* Servlet-specific subclass of {@link HandlerMethodInvoker}.
769+
* Servlet-specific subclass of {@code HandlerMethodInvoker}.
772770
*/
773-
private class ServletHandlerMethodInvoker extends HandlerMethodInvoker {
771+
@SuppressWarnings("deprecation")
772+
private class ServletHandlerMethodInvoker extends org.springframework.web.bind.annotation.support.HandlerMethodInvoker {
774773

775774
private boolean responseArgumentUsed = false;
776775

777-
private ServletHandlerMethodInvoker(HandlerMethodResolver resolver) {
776+
private ServletHandlerMethodInvoker(org.springframework.web.bind.annotation.support.HandlerMethodResolver resolver) {
778777
super(resolver, webBindingInitializer, sessionAttributeStore, parameterNameDiscoverer,
779778
customArgumentResolvers, messageConverters);
780779
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import org.springframework.web.context.request.WebRequest;
4747
import org.springframework.web.multipart.support.MissingServletRequestPartException;
4848
import org.springframework.web.servlet.NoHandlerFoundException;
49-
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException;
5049
import org.springframework.web.util.WebUtils;
5150

5251
/**
@@ -99,8 +98,9 @@ public abstract class ResponseEntityExceptionHandler {
9998
* @param ex the target exception
10099
* @param request the current request
101100
*/
101+
@SuppressWarnings("deprecation")
102102
@ExceptionHandler({
103-
NoSuchRequestHandlingMethodException.class,
103+
org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException.class,
104104
HttpRequestMethodNotSupportedException.class,
105105
HttpMediaTypeNotSupportedException.class,
106106
HttpMediaTypeNotAcceptableException.class,
@@ -118,9 +118,9 @@ public abstract class ResponseEntityExceptionHandler {
118118
})
119119
public final ResponseEntity<Object> handleException(Exception ex, WebRequest request) {
120120
HttpHeaders headers = new HttpHeaders();
121-
if (ex instanceof NoSuchRequestHandlingMethodException) {
121+
if (ex instanceof org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException) {
122122
HttpStatus status = HttpStatus.NOT_FOUND;
123-
return handleNoSuchRequestHandlingMethod((NoSuchRequestHandlingMethodException) ex, headers, status, request);
123+
return handleNoSuchRequestHandlingMethod((org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException) ex, headers, status, request);
124124
}
125125
else if (ex instanceof HttpRequestMethodNotSupportedException) {
126126
HttpStatus status = HttpStatus.METHOD_NOT_ALLOWED;
@@ -213,8 +213,10 @@ protected ResponseEntity<Object> handleExceptionInternal(Exception ex, Object bo
213213
* @param status the selected response status
214214
* @param request the current request
215215
* @return a {@code ResponseEntity} instance
216+
* @deprecated as of 4.3, along with {@link org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException}
216217
*/
217-
protected ResponseEntity<Object> handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex,
218+
@Deprecated
219+
protected ResponseEntity<Object> handleNoSuchRequestHandlingMethod(org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException ex,
218220
HttpHeaders headers, HttpStatus status, WebRequest request) {
219221

220222
pageNotFoundLogger.warn(ex.getMessage());

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/multiaction/AbstractUrlMethodNameResolver.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
*
3535
* @author Juergen Hoeller
3636
* @since 14.01.2004
37+
* @deprecated as of 4.3, in favor of annotation-driven handler methods
3738
*/
39+
@Deprecated
3840
public abstract class AbstractUrlMethodNameResolver implements MethodNameResolver {
3941

4042
/** Logger available to subclasses */

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/multiaction/InternalPathMethodNameResolver.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
*
3636
* @author Rod Johnson
3737
* @author Juergen Hoeller
38-
*/
38+
* @deprecated as of 4.3, in favor of annotation-driven handler methods
39+
*/
40+
@Deprecated
3941
public class InternalPathMethodNameResolver extends AbstractUrlMethodNameResolver {
4042

4143
private String prefix = "";

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/multiaction/MethodNameResolver.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
*
2929
* @author Rod Johnson
3030
* @see MultiActionController#setMethodNameResolver
31+
* @deprecated as of 4.3, in favor of annotation-driven handler methods
3132
*/
33+
@Deprecated
3234
public interface MethodNameResolver {
3335

3436
/**

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/multiaction/MultiActionController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@
127127
* @see ParameterMethodNameResolver
128128
* @see org.springframework.web.servlet.mvc.LastModified#getLastModified
129129
* @see org.springframework.web.bind.ServletRequestDataBinder
130+
* @deprecated as of 4.3, in favor of annotation-driven handler methods
130131
*/
132+
@Deprecated
131133
public class MultiActionController extends AbstractController implements LastModified {
132134

133135
/** Suffix for last-modified methods */

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/multiaction/NoSuchRequestHandlingMethodException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
* @author Rod Johnson
3131
* @author Juergen Hoeller
3232
* @see MethodNameResolver#getHandlerMethodName(javax.servlet.http.HttpServletRequest)
33+
* @deprecated as of 4.3, in favor of annotation-driven handler methods
3334
*/
35+
@Deprecated
3436
@SuppressWarnings("serial")
3537
public class NoSuchRequestHandlingMethodException extends ServletException {
3638

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/multiaction/ParameterMethodNameResolver.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@
7979
* @see #setMethodParamNames
8080
* @see #setLogicalMappings
8181
* @see #setDefaultMethodName
82+
* @deprecated as of 4.3, in favor of annotation-driven handler methods
8283
*/
84+
@Deprecated
8385
public class ParameterMethodNameResolver implements MethodNameResolver {
8486

8587
/**

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/multiaction/PropertiesMethodNameResolver.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@
4545
* @author Juergen Hoeller
4646
* @see java.util.Properties
4747
* @see org.springframework.util.AntPathMatcher
48+
* @deprecated as of 4.3, in favor of annotation-driven handler methods
4849
*/
50+
@Deprecated
4951
public class PropertiesMethodNameResolver extends AbstractUrlMethodNameResolver
5052
implements InitializingBean {
5153

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/AbstractControllerUrlHandlerMapping.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
* @since 2.5.3
3232
* @see ControllerClassNameHandlerMapping
3333
* @see ControllerBeanNameHandlerMapping
34+
* @deprecated as of 4.3, in favor of annotation-driven handler methods
3435
*/
36+
@Deprecated
3537
public abstract class AbstractControllerUrlHandlerMapping extends AbstractDetectingUrlHandlerMapping {
3638

3739
private ControllerTypePredicate predicate = new AnnotationControllerTypePredicate();

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/AnnotationControllerTypePredicate.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
*
2626
* @author Juergen Hoeller
2727
* @since 2.5.3
28+
* @deprecated as of 4.3, in favor of annotation-driven handler methods
2829
*/
30+
@Deprecated
2931
class AnnotationControllerTypePredicate extends ControllerTypePredicate {
3032

3133
@Override

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/ControllerBeanNameHandlerMapping.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
* @since 2.5.3
3838
* @see ControllerClassNameHandlerMapping
3939
* @see org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping
40+
* @deprecated as of 4.3, in favor of annotation-driven handler methods
4041
*/
42+
@Deprecated
4143
public class ControllerBeanNameHandlerMapping extends AbstractControllerUrlHandlerMapping {
4244

4345
private String urlPrefix = "";

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/ControllerClassNameHandlerMapping.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import org.springframework.util.ClassUtils;
2020
import org.springframework.util.StringUtils;
21-
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
2221

2322
/**
2423
* Implementation of {@link org.springframework.web.servlet.HandlerMapping} that
@@ -36,15 +35,15 @@
3635
* <li>{@code HomeController} -> {@code /home*}</li>
3736
* </ul>
3837
*
39-
* <p>For {@link MultiActionController MultiActionControllers} and {@code @Controller}
38+
* <p>For {@code MultiActionController MultiActionControllers} and {@code @Controller}
4039
* beans, a similar mapping is registered, except that all sub-paths are registered
4140
* using the trailing wildcard pattern {@code /*}. For example:
4241
* <ul>
4342
* <li>{@code WelcomeController} -> {@code /welcome}, {@code /welcome/*}</li>
4443
* <li>{@code CatalogController} -> {@code /catalog}, {@code /catalog/*}</li>
4544
* </ul>
4645
*
47-
* <p>For {@link MultiActionController} it is often useful to use
46+
* <p>For {@code MultiActionController} it is often useful to use
4847
* this mapping strategy in conjunction with the
4948
* {@link org.springframework.web.servlet.mvc.multiaction.InternalPathMethodNameResolver}.
5049
*
@@ -56,7 +55,9 @@
5655
* @since 2.0
5756
* @see org.springframework.web.servlet.mvc.Controller
5857
* @see org.springframework.web.servlet.mvc.multiaction.MultiActionController
58+
* @deprecated as of 4.3, in favor of annotation-driven handler methods
5959
*/
60+
@Deprecated
6061
public class ControllerClassNameHandlerMapping extends AbstractControllerUrlHandlerMapping {
6162

6263
/**

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/ControllerTypePredicate.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,24 @@
1717
package org.springframework.web.servlet.mvc.support;
1818

1919
import org.springframework.web.servlet.mvc.Controller;
20-
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
2120

2221
/**
2322
* Internal helper class that identifies controller types.
2423
*
2524
* @author Juergen Hoeller
2625
* @since 2.5.3
26+
* @deprecated as of 4.3, in favor of annotation-driven handler methods
2727
*/
28+
@Deprecated
2829
class ControllerTypePredicate {
2930

3031
public boolean isControllerType(Class<?> beanClass) {
3132
return Controller.class.isAssignableFrom(beanClass);
3233
}
3334

35+
@SuppressWarnings("deprecation")
3436
public boolean isMultiActionControllerType(Class<?> beanClass) {
35-
return MultiActionController.class.isAssignableFrom(beanClass);
37+
return org.springframework.web.servlet.mvc.multiaction.MultiActionController.class.isAssignableFrom(beanClass);
3638
}
3739

3840
}

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import org.springframework.web.servlet.ModelAndView;
5050
import org.springframework.web.servlet.NoHandlerFoundException;
5151
import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;
52-
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException;
5352

5453
/**
5554
* Default implementation of the {@link org.springframework.web.servlet.HandlerExceptionResolver
@@ -101,13 +100,14 @@ public DefaultHandlerExceptionResolver() {
101100

102101

103102
@Override
103+
@SuppressWarnings("deprecation")
104104
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response,
105105
Object handler, Exception ex) {
106106

107107
try {
108-
if (ex instanceof NoSuchRequestHandlingMethodException) {
109-
return handleNoSuchRequestHandlingMethod((NoSuchRequestHandlingMethodException) ex, request, response,
110-
handler);
108+
if (ex instanceof org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException) {
109+
return handleNoSuchRequestHandlingMethod((org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException) ex,
110+
request, response, handler);
111111
}
112112
else if (ex instanceof HttpRequestMethodNotSupportedException) {
113113
return handleHttpRequestMethodNotSupported((HttpRequestMethodNotSupportedException) ex, request,
@@ -180,8 +180,10 @@ else if (ex instanceof NoHandlerFoundException) {
180180
* at the time of the exception (for example, if multipart resolution failed)
181181
* @return an empty ModelAndView indicating the exception was handled
182182
* @throws IOException potentially thrown from response.sendError()
183+
* @deprecated as of 4.3, along with {@link org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException}
183184
*/
184-
protected ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex,
185+
@Deprecated
186+
protected ModelAndView handleNoSuchRequestHandlingMethod(org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException ex,
185187
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
186188

187189
pageNotFoundLogger.warn(ex.getMessage());

0 commit comments

Comments
 (0)