Skip to content

Commit

Permalink
Consistent deprecation of outdated MVC infrastructure classes
Browse files Browse the repository at this point in the history
Issue: SPR-14128
  • Loading branch information
jhoeller committed Apr 7, 2016
1 parent 4ea4257 commit ed14ae6
Show file tree
Hide file tree
Showing 19 changed files with 68 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
* @author Juergen Hoeller
* @since 2.5.6
* @see HandlerMethodInvoker#invokeHandlerMethod
* @deprecated as of 4.3, in favor of the {@code HandlerMethod}-based MVC infrastructure
*/
@Deprecated
@SuppressWarnings("serial")
public class HandlerMethodInvocationException extends NestedRuntimeException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@
* @author Arjen Poutsma
* @since 2.5.2
* @see #invokeHandlerMethod
* @deprecated as of 4.3, in favor of the {@code HandlerMethod}-based MVC infrastructure
*/
@Deprecated
public class HandlerMethodInvoker {

private static final String MODEL_KEY_PREFIX_STALE = SessionAttributeStore.class.getName() + ".STALE.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
* @see org.springframework.web.bind.annotation.InitBinder
* @see org.springframework.web.bind.annotation.ModelAttribute
* @see org.springframework.web.bind.annotation.SessionAttributes
* @deprecated as of 4.3, in favor of the {@code HandlerMethod}-based MVC infrastructure
*/
@Deprecated
public class HandlerMethodResolver {

private final Set<Method> handlerMethods = new LinkedHashSet<Method>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
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;
Expand Down Expand Up @@ -434,9 +432,10 @@ protected PortletRequestDataBinder createBinder(PortletRequest request, Object t


/**
* Portlet-specific subclass of {@link HandlerMethodResolver}.
* Portlet-specific subclass of {@code HandlerMethodResolver}.
*/
private static class PortletHandlerMethodResolver extends HandlerMethodResolver {
@SuppressWarnings("deprecation")
private static class PortletHandlerMethodResolver extends org.springframework.web.bind.annotation.support.HandlerMethodResolver {

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

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


/**
* Portlet-specific subclass of {@link HandlerMethodInvoker}.
* Portlet-specific subclass of {@code HandlerMethodInvoker}.
*/
private class PortletHandlerMethodInvoker extends HandlerMethodInvoker {
@SuppressWarnings("deprecation")
private class PortletHandlerMethodInvoker extends org.springframework.web.bind.annotation.support.HandlerMethodInvoker {

public PortletHandlerMethodInvoker(HandlerMethodResolver resolver) {
public PortletHandlerMethodInvoker(org.springframework.web.bind.annotation.support.HandlerMethodResolver resolver) {
super(resolver, webBindingInitializer, sessionAttributeStore,
parameterNameDiscoverer, customArgumentResolvers, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@
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;
Expand All @@ -110,9 +108,6 @@
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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -255,7 +251,7 @@ public void setPathMatcher(PathMatcher pathMatcher) {
* <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;
}

Expand Down Expand Up @@ -524,9 +520,10 @@ protected HttpOutputMessage createHttpOutputMessage(HttpServletResponse servletR


/**
* 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>();

Expand Down Expand Up @@ -674,7 +671,8 @@ else if (useTypeLevelMapping(request)) {
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());
}
}

Expand Down Expand Up @@ -768,13 +766,14 @@ private void extractHandlerMethodUriTemplates(String mappedPattern, String looku


/**
* 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
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;

/**
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -213,8 +213,10 @@ protected ResponseEntity<Object> handleExceptionInternal(Exception ex, Object bo
* @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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
*
* @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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
*
* @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 = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
*
* @author Rod Johnson
* @see MultiActionController#setMethodNameResolver
* @deprecated as of 4.3, in favor of annotation-driven handler methods
*/
@Deprecated
public interface MethodNameResolver {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@
* @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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
* @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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@
* @see #setMethodParamNames
* @see #setLogicalMappings
* @see #setDefaultMethodName
* @deprecated as of 4.3, in favor of annotation-driven handler methods
*/
@Deprecated
public class ParameterMethodNameResolver implements MethodNameResolver {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
* @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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
* @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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
*
* @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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
* @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 = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

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
Expand All @@ -36,15 +35,15 @@
* <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>
* <li>{@code WelcomeController} -> {@code /welcome}, {@code /welcome/*}</li>
* <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}.
*
Expand All @@ -56,7 +55,9 @@
* @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 {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
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
Expand Down Expand Up @@ -101,13 +100,14 @@ public DefaultHandlerExceptionResolver() {


@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,
Expand Down Expand Up @@ -180,8 +180,10 @@ else if (ex instanceof NoHandlerFoundException) {
* 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());
Expand Down

0 comments on commit ed14ae6

Please sign in to comment.