Polishing
This commit is contained in:
@@ -153,6 +153,28 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
|
||||
return this.mappingRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the given mapping.
|
||||
* <p>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.
|
||||
* <p>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<T> 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<T> 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<T> extends AbstractHandlerMap
|
||||
return handlerMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract and return the URL paths contained in a mapping.
|
||||
*/
|
||||
protected abstract Set<String> getMappingPathPatterns(T mapping);
|
||||
|
||||
/**
|
||||
* Extract and return the CORS configuration for the mapping.
|
||||
*/
|
||||
@@ -291,25 +291,8 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
|
||||
protected void handlerMethodsInitialized(Map<T, HandlerMethod> handlerMethods) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the given mapping.
|
||||
* <p>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.
|
||||
* <p>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<T> 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<T> getMappingComparator(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* Invoked when a matching mapping is found.
|
||||
* @param mapping the matching mapping
|
||||
@@ -452,6 +418,48 @@ public abstract class AbstractHandlerMethodMapping<T> 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<String> 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<T> getMappingComparator(HttpServletRequest request);
|
||||
|
||||
|
||||
/**
|
||||
* A registry that maintains all mappings to handler methods, exposing methods
|
||||
* to perform lookups and providing concurrent access.
|
||||
|
||||
@@ -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}.
|
||||
*
|
||||
* <p>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
|
||||
* <p>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.
|
||||
*
|
||||
* <p>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.
|
||||
* <p>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.
|
||||
*
|
||||
* <p>A {@link WebDataBinder} is invoked to apply type conversion to resolved
|
||||
* path variable values that don't yet match the method parameter type.
|
||||
* <p>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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user