Consistent deprecation of outdated MVC infrastructure classes
Issue: SPR-14128
This commit is contained in:
@@ -96,8 +96,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.bind.annotation.support.HandlerMethodInvoker;
|
||||
import org.springframework.web.bind.annotation.support.HandlerMethodResolver;
|
||||
import org.springframework.web.bind.support.DefaultSessionAttributeStore;
|
||||
import org.springframework.web.bind.support.SessionAttributeStore;
|
||||
import org.springframework.web.bind.support.WebArgumentResolver;
|
||||
@@ -110,9 +108,6 @@ import org.springframework.web.servlet.HandlerAdapter;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.View;
|
||||
import org.springframework.web.servlet.mvc.multiaction.InternalPathMethodNameResolver;
|
||||
import org.springframework.web.servlet.mvc.multiaction.MethodNameResolver;
|
||||
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException;
|
||||
import org.springframework.web.servlet.support.RequestContextUtils;
|
||||
import org.springframework.web.servlet.support.WebContentGenerator;
|
||||
import org.springframework.web.util.UrlPathHelper;
|
||||
@@ -164,7 +159,8 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
|
||||
|
||||
private PathMatcher pathMatcher = new AntPathMatcher();
|
||||
|
||||
private MethodNameResolver methodNameResolver = new InternalPathMethodNameResolver();
|
||||
private org.springframework.web.servlet.mvc.multiaction.MethodNameResolver methodNameResolver =
|
||||
new org.springframework.web.servlet.mvc.multiaction.InternalPathMethodNameResolver();
|
||||
|
||||
private WebBindingInitializer webBindingInitializer;
|
||||
|
||||
@@ -255,7 +251,7 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
|
||||
* <p>Will only kick in when the handler method cannot be resolved uniquely
|
||||
* through the annotation metadata already.
|
||||
*/
|
||||
public void setMethodNameResolver(MethodNameResolver methodNameResolver) {
|
||||
public void setMethodNameResolver(org.springframework.web.servlet.mvc.multiaction.MethodNameResolver methodNameResolver) {
|
||||
this.methodNameResolver = methodNameResolver;
|
||||
}
|
||||
|
||||
@@ -524,9 +520,10 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
|
||||
|
||||
|
||||
/**
|
||||
* Servlet-specific subclass of {@link HandlerMethodResolver}.
|
||||
* Servlet-specific subclass of {@code HandlerMethodResolver}.
|
||||
*/
|
||||
private class ServletHandlerMethodResolver extends HandlerMethodResolver {
|
||||
@SuppressWarnings("deprecation")
|
||||
private class ServletHandlerMethodResolver extends org.springframework.web.bind.annotation.support.HandlerMethodResolver {
|
||||
|
||||
private final Map<Method, RequestMappingInfo> mappings = new HashMap<Method, RequestMappingInfo>();
|
||||
|
||||
@@ -674,7 +671,8 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
|
||||
if (!allowedMethods.isEmpty()) {
|
||||
throw new HttpRequestMethodNotSupportedException(request.getMethod(), StringUtils.toStringArray(allowedMethods));
|
||||
}
|
||||
throw new NoSuchRequestHandlingMethodException(lookupPath, request.getMethod(), request.getParameterMap());
|
||||
throw new org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException(
|
||||
lookupPath, request.getMethod(), request.getParameterMap());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -768,13 +766,14 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator
|
||||
|
||||
|
||||
/**
|
||||
* Servlet-specific subclass of {@link HandlerMethodInvoker}.
|
||||
* Servlet-specific subclass of {@code HandlerMethodInvoker}.
|
||||
*/
|
||||
private class ServletHandlerMethodInvoker extends HandlerMethodInvoker {
|
||||
@SuppressWarnings("deprecation")
|
||||
private class ServletHandlerMethodInvoker extends org.springframework.web.bind.annotation.support.HandlerMethodInvoker {
|
||||
|
||||
private boolean responseArgumentUsed = false;
|
||||
|
||||
private ServletHandlerMethodInvoker(HandlerMethodResolver resolver) {
|
||||
private ServletHandlerMethodInvoker(org.springframework.web.bind.annotation.support.HandlerMethodResolver resolver) {
|
||||
super(resolver, webBindingInitializer, sessionAttributeStore, parameterNameDiscoverer,
|
||||
customArgumentResolvers, messageConverters);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
import org.springframework.web.multipart.support.MissingServletRequestPartException;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
@@ -99,8 +98,9 @@ public abstract class ResponseEntityExceptionHandler {
|
||||
* @param ex the target exception
|
||||
* @param request the current request
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@ExceptionHandler({
|
||||
NoSuchRequestHandlingMethodException.class,
|
||||
org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException.class,
|
||||
HttpRequestMethodNotSupportedException.class,
|
||||
HttpMediaTypeNotSupportedException.class,
|
||||
HttpMediaTypeNotAcceptableException.class,
|
||||
@@ -118,9 +118,9 @@ public abstract class ResponseEntityExceptionHandler {
|
||||
})
|
||||
public final ResponseEntity<Object> handleException(Exception ex, WebRequest request) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
if (ex instanceof NoSuchRequestHandlingMethodException) {
|
||||
if (ex instanceof org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException) {
|
||||
HttpStatus status = HttpStatus.NOT_FOUND;
|
||||
return handleNoSuchRequestHandlingMethod((NoSuchRequestHandlingMethodException) ex, headers, status, request);
|
||||
return handleNoSuchRequestHandlingMethod((org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException) ex, headers, status, request);
|
||||
}
|
||||
else if (ex instanceof HttpRequestMethodNotSupportedException) {
|
||||
HttpStatus status = HttpStatus.METHOD_NOT_ALLOWED;
|
||||
@@ -213,8 +213,10 @@ public abstract class ResponseEntityExceptionHandler {
|
||||
* @param status the selected response status
|
||||
* @param request the current request
|
||||
* @return a {@code ResponseEntity} instance
|
||||
* @deprecated as of 4.3, along with {@link org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException}
|
||||
*/
|
||||
protected ResponseEntity<Object> handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex,
|
||||
@Deprecated
|
||||
protected ResponseEntity<Object> handleNoSuchRequestHandlingMethod(org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException ex,
|
||||
HttpHeaders headers, HttpStatus status, WebRequest request) {
|
||||
|
||||
pageNotFoundLogger.warn(ex.getMessage());
|
||||
|
||||
@@ -34,7 +34,9 @@ import org.springframework.web.util.UrlPathHelper;
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 14.01.2004
|
||||
* @deprecated as of 4.3, in favor of annotation-driven handler methods
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class AbstractUrlMethodNameResolver implements MethodNameResolver {
|
||||
|
||||
/** Logger available to subclasses */
|
||||
|
||||
@@ -35,7 +35,9 @@ import org.springframework.web.util.WebUtils;
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
* @deprecated as of 4.3, in favor of annotation-driven handler methods
|
||||
*/
|
||||
@Deprecated
|
||||
public class InternalPathMethodNameResolver extends AbstractUrlMethodNameResolver {
|
||||
|
||||
private String prefix = "";
|
||||
|
||||
@@ -28,7 +28,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @see MultiActionController#setMethodNameResolver
|
||||
* @deprecated as of 4.3, in favor of annotation-driven handler methods
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MethodNameResolver {
|
||||
|
||||
/**
|
||||
|
||||
@@ -127,7 +127,9 @@ import org.springframework.web.servlet.mvc.LastModified;
|
||||
* @see ParameterMethodNameResolver
|
||||
* @see org.springframework.web.servlet.mvc.LastModified#getLastModified
|
||||
* @see org.springframework.web.bind.ServletRequestDataBinder
|
||||
* @deprecated as of 4.3, in favor of annotation-driven handler methods
|
||||
*/
|
||||
@Deprecated
|
||||
public class MultiActionController extends AbstractController implements LastModified {
|
||||
|
||||
/** Suffix for last-modified methods */
|
||||
|
||||
@@ -30,7 +30,9 @@ import org.springframework.web.util.UrlPathHelper;
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @see MethodNameResolver#getHandlerMethodName(javax.servlet.http.HttpServletRequest)
|
||||
* @deprecated as of 4.3, in favor of annotation-driven handler methods
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("serial")
|
||||
public class NoSuchRequestHandlingMethodException extends ServletException {
|
||||
|
||||
|
||||
@@ -79,7 +79,9 @@ import org.springframework.web.util.WebUtils;
|
||||
* @see #setMethodParamNames
|
||||
* @see #setLogicalMappings
|
||||
* @see #setDefaultMethodName
|
||||
* @deprecated as of 4.3, in favor of annotation-driven handler methods
|
||||
*/
|
||||
@Deprecated
|
||||
public class ParameterMethodNameResolver implements MethodNameResolver {
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,9 @@ import org.springframework.util.PathMatcher;
|
||||
* @author Juergen Hoeller
|
||||
* @see java.util.Properties
|
||||
* @see org.springframework.util.AntPathMatcher
|
||||
* @deprecated as of 4.3, in favor of annotation-driven handler methods
|
||||
*/
|
||||
@Deprecated
|
||||
public class PropertiesMethodNameResolver extends AbstractUrlMethodNameResolver
|
||||
implements InitializingBean {
|
||||
|
||||
|
||||
@@ -31,7 +31,9 @@ import org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMappin
|
||||
* @since 2.5.3
|
||||
* @see ControllerClassNameHandlerMapping
|
||||
* @see ControllerBeanNameHandlerMapping
|
||||
* @deprecated as of 4.3, in favor of annotation-driven handler methods
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class AbstractControllerUrlHandlerMapping extends AbstractDetectingUrlHandlerMapping {
|
||||
|
||||
private ControllerTypePredicate predicate = new AnnotationControllerTypePredicate();
|
||||
|
||||
@@ -25,7 +25,9 @@ import org.springframework.stereotype.Controller;
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5.3
|
||||
* @deprecated as of 4.3, in favor of annotation-driven handler methods
|
||||
*/
|
||||
@Deprecated
|
||||
class AnnotationControllerTypePredicate extends ControllerTypePredicate {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,9 @@ import org.springframework.util.StringUtils;
|
||||
* @since 2.5.3
|
||||
* @see ControllerClassNameHandlerMapping
|
||||
* @see org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping
|
||||
* @deprecated as of 4.3, in favor of annotation-driven handler methods
|
||||
*/
|
||||
@Deprecated
|
||||
public class ControllerBeanNameHandlerMapping extends AbstractControllerUrlHandlerMapping {
|
||||
|
||||
private String urlPrefix = "";
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.web.servlet.mvc.support;
|
||||
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
|
||||
|
||||
/**
|
||||
* Implementation of {@link org.springframework.web.servlet.HandlerMapping} that
|
||||
@@ -36,7 +35,7 @@ import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
|
||||
* <li>{@code HomeController} -> {@code /home*}</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>For {@link MultiActionController MultiActionControllers} and {@code @Controller}
|
||||
* <p>For {@code MultiActionController MultiActionControllers} and {@code @Controller}
|
||||
* beans, a similar mapping is registered, except that all sub-paths are registered
|
||||
* using the trailing wildcard pattern {@code /*}. For example:
|
||||
* <ul>
|
||||
@@ -44,7 +43,7 @@ import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
|
||||
* <li>{@code CatalogController} -> {@code /catalog}, {@code /catalog/*}</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>For {@link MultiActionController} it is often useful to use
|
||||
* <p>For {@code MultiActionController} it is often useful to use
|
||||
* this mapping strategy in conjunction with the
|
||||
* {@link org.springframework.web.servlet.mvc.multiaction.InternalPathMethodNameResolver}.
|
||||
*
|
||||
@@ -56,7 +55,9 @@ import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
|
||||
* @since 2.0
|
||||
* @see org.springframework.web.servlet.mvc.Controller
|
||||
* @see org.springframework.web.servlet.mvc.multiaction.MultiActionController
|
||||
* @deprecated as of 4.3, in favor of annotation-driven handler methods
|
||||
*/
|
||||
@Deprecated
|
||||
public class ControllerClassNameHandlerMapping extends AbstractControllerUrlHandlerMapping {
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,22 +17,24 @@
|
||||
package org.springframework.web.servlet.mvc.support;
|
||||
|
||||
import org.springframework.web.servlet.mvc.Controller;
|
||||
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
|
||||
|
||||
/**
|
||||
* Internal helper class that identifies controller types.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5.3
|
||||
* @deprecated as of 4.3, in favor of annotation-driven handler methods
|
||||
*/
|
||||
@Deprecated
|
||||
class ControllerTypePredicate {
|
||||
|
||||
public boolean isControllerType(Class<?> beanClass) {
|
||||
return Controller.class.isAssignableFrom(beanClass);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isMultiActionControllerType(Class<?> beanClass) {
|
||||
return MultiActionController.class.isAssignableFrom(beanClass);
|
||||
return org.springframework.web.servlet.mvc.multiaction.MultiActionController.class.isAssignableFrom(beanClass);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ import org.springframework.web.multipart.support.MissingServletRequestPartExcept
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;
|
||||
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException;
|
||||
|
||||
/**
|
||||
* Default implementation of the {@link org.springframework.web.servlet.HandlerExceptionResolver
|
||||
@@ -101,13 +100,14 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response,
|
||||
Object handler, Exception ex) {
|
||||
|
||||
try {
|
||||
if (ex instanceof NoSuchRequestHandlingMethodException) {
|
||||
return handleNoSuchRequestHandlingMethod((NoSuchRequestHandlingMethodException) ex, request, response,
|
||||
handler);
|
||||
if (ex instanceof org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException) {
|
||||
return handleNoSuchRequestHandlingMethod((org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException) ex,
|
||||
request, response, handler);
|
||||
}
|
||||
else if (ex instanceof HttpRequestMethodNotSupportedException) {
|
||||
return handleHttpRequestMethodNotSupported((HttpRequestMethodNotSupportedException) ex, request,
|
||||
@@ -180,8 +180,10 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
|
||||
* at the time of the exception (for example, if multipart resolution failed)
|
||||
* @return an empty ModelAndView indicating the exception was handled
|
||||
* @throws IOException potentially thrown from response.sendError()
|
||||
* @deprecated as of 4.3, along with {@link org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException}
|
||||
*/
|
||||
protected ModelAndView handleNoSuchRequestHandlingMethod(NoSuchRequestHandlingMethodException ex,
|
||||
@Deprecated
|
||||
protected ModelAndView handleNoSuchRequestHandlingMethod(org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException ex,
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
|
||||
|
||||
pageNotFoundLogger.warn(ex.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user