diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java index c0daff60dd..266cdfb78e 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java @@ -153,6 +153,28 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap return this.mappingRegistry; } + /** + * Register the given mapping. + *

This method may be invoked at runtime after initialization has completed. + * @param mapping the mapping for the handler method + * @param handler the handler + * @param method the method + */ + public void registerMapping(T mapping, Object handler, Method method) { + this.mappingRegistry.register(mapping, handler, method); + } + + /** + * Un-register the given mapping. + *

This method may be invoked at runtime after initialization has completed. + * @param mapping the mapping to unregister + */ + public void unregisterMapping(T mapping) { + this.mappingRegistry.unregister(mapping); + } + + + // Handler method detection /** * Detects handler methods at initialization. @@ -196,13 +218,6 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap handlerMethodsInitialized(getHandlerMethods()); } - /** - * Whether the given type is a handler with handler methods. - * @param beanType the type of the bean being checked - * @return "true" if this a handler type, "false" otherwise. - */ - protected abstract boolean isHandler(Class beanType); - /** * Look for handler methods in a handler. * @param handler the bean name of a handler or a handler instance @@ -230,16 +245,6 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap } } - /** - * Provide the mapping for a handler method. A method for which no - * mapping can be provided is not a handler method. - * @param method the method to provide a mapping for - * @param handlerType the handler type, possibly a sub-type of the method's - * declaring class - * @return the mapping, or {@code null} if the method is not mapped - */ - protected abstract T getMappingForMethod(Method method, Class handlerType); - /** * Register a handler method and its unique mapping. Invoked at startup for * each detected handler method. @@ -272,11 +277,6 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap return handlerMethod; } - /** - * Extract and return the URL paths contained in a mapping. - */ - protected abstract Set getMappingPathPatterns(T mapping); - /** * Extract and return the CORS configuration for the mapping. */ @@ -291,25 +291,8 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap protected void handlerMethodsInitialized(Map handlerMethods) { } - /** - * Register the given mapping. - *

This method may be invoked at runtime after initialization has completed. - * @param mapping the mapping for the handler method - * @param handler the handler - * @param method the method - */ - public void registerMapping(T mapping, Object handler, Method method) { - this.mappingRegistry.register(mapping, handler, method); - } - /** - * Un-register the given mapping. - *

This method may be invoked at runtime after initialization has completed. - * @param mapping the mapping to unregister - */ - public void unregisterMapping(T mapping) { - this.mappingRegistry.unregister(mapping); - } + // Handler method lookup /** * Look up a handler method for the given request. @@ -395,23 +378,6 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap } } - /** - * Check if a mapping matches the current request and return a (potentially - * new) mapping with conditions relevant to the current request. - * @param mapping the mapping to get a match for - * @param request the current HTTP servlet request - * @return the match, or {@code null} if the mapping doesn't match - */ - protected abstract T getMatchingMapping(T mapping, HttpServletRequest request); - - /** - * Return a comparator for sorting matching mappings. - * The returned comparator should sort 'better' matches higher. - * @param request the current request - * @return the comparator (never {@code null}) - */ - protected abstract Comparator getMappingComparator(HttpServletRequest request); - /** * Invoked when a matching mapping is found. * @param mapping the matching mapping @@ -452,6 +418,48 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap } + // Abstract template methods + + /** + * Whether the given type is a handler with handler methods. + * @param beanType the type of the bean being checked + * @return "true" if this a handler type, "false" otherwise. + */ + protected abstract boolean isHandler(Class beanType); + + /** + * Provide the mapping for a handler method. A method for which no + * mapping can be provided is not a handler method. + * @param method the method to provide a mapping for + * @param handlerType the handler type, possibly a sub-type of the method's + * declaring class + * @return the mapping, or {@code null} if the method is not mapped + */ + protected abstract T getMappingForMethod(Method method, Class handlerType); + + /** + * Extract and return the URL paths contained in a mapping. + */ + protected abstract Set getMappingPathPatterns(T mapping); + + /** + * Check if a mapping matches the current request and return a (potentially + * new) mapping with conditions relevant to the current request. + * @param mapping the mapping to get a match for + * @param request the current HTTP servlet request + * @return the match, or {@code null} if the mapping doesn't match + */ + protected abstract T getMatchingMapping(T mapping, HttpServletRequest request); + + /** + * Return a comparator for sorting matching mappings. + * The returned comparator should sort 'better' matches higher. + * @param request the current request + * @return the comparator (never {@code null}) + */ + protected abstract Comparator getMappingComparator(HttpServletRequest request); + + /** * A registry that maintains all mappings to handler methods, exposing methods * to perform lookups and providing concurrent access. diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolver.java index e2e30c447c..d7b1cb522e 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,6 @@ import org.springframework.web.bind.annotation.ValueConstants; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver; -import org.springframework.web.method.annotation.RequestParamMapMethodArgumentResolver; import org.springframework.web.method.support.ModelAndViewContainer; import org.springframework.web.method.support.UriComponentsContributor; import org.springframework.web.servlet.HandlerMapping; @@ -43,22 +42,18 @@ import org.springframework.web.util.UriComponentsBuilder; /** * Resolves method arguments annotated with an @{@link PathVariable}. * - *

An @{@link PathVariable} is a named value that gets resolved from a URI - * template variable. It is always required and does not have a default value - * to fall back on. See the base class + *

An @{@link PathVariable} is a named value that gets resolved from a URI template variable. + * It is always required and does not have a default value to fall back on. See the base class * {@link org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver} * for more information on how named values are processed. * - *

If the method parameter type is {@link Map}, the name specified in the - * annotation is used to resolve the URI variable String value. The value is - * then converted to a {@link Map} via type conversion assuming a suitable - * {@link Converter} or {@link PropertyEditor} has been registered. - * Or if the annotation does not specify name the - * {@link RequestParamMapMethodArgumentResolver} is used instead to provide - * access to all URI variables in a map. + *

If the method parameter type is {@link Map}, the name specified in the annotation is used + * to resolve the URI variable String value. The value is then converted to a {@link Map} via + * type conversion, assuming a suitable {@link Converter} or {@link PropertyEditor} has been + * registered. * - *

A {@link WebDataBinder} is invoked to apply type conversion to resolved - * path variable values that don't yet match the method parameter type. + *

A {@link WebDataBinder} is invoked to apply type conversion to resolved path variable + * values that don't yet match the method parameter type. * * @author Rossen Stoyanchev * @author Arjen Poutsma diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java index ce2e89e7bb..7ccc938ced 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java @@ -28,7 +28,6 @@ import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; - import javax.servlet.http.HttpServletRequest; import org.springframework.core.io.AbstractResource;