提交 d97a4b5b 编写于 作者: J Juergen Hoeller

polishing

上级 59657105
...@@ -25,13 +25,11 @@ import java.util.LinkedHashMap; ...@@ -25,13 +25,11 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContextException;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
...@@ -62,6 +60,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap ...@@ -62,6 +60,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
private final MultiValueMap<String, T> urlMap = new LinkedMultiValueMap<String, T>(); private final MultiValueMap<String, T> urlMap = new LinkedMultiValueMap<String, T>();
/** /**
* Whether to detect handler methods in beans in ancestor ApplicationContexts. * Whether to detect handler methods in beans in ancestor ApplicationContexts.
* <p>Default is "false": Only beans in the current ApplicationContext are * <p>Default is "false": Only beans in the current ApplicationContext are
...@@ -78,15 +77,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap ...@@ -78,15 +77,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
* Return a map with all handler methods and their mappings. * Return a map with all handler methods and their mappings.
*/ */
public Map<T, HandlerMethod> getHandlerMethods() { public Map<T, HandlerMethod> getHandlerMethods() {
return Collections.unmodifiableMap(handlerMethods); return Collections.unmodifiableMap(this.handlerMethods);
}
/**
* ApplicationContext initialization.
*/
@Override
public void initApplicationContext() throws ApplicationContextException {
super.initApplicationContext();
} }
/** /**
...@@ -158,7 +149,6 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap ...@@ -158,7 +149,6 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
/** /**
* Provide the mapping for a handler method. A method for which no * Provide the mapping for a handler method. A method for which no
* mapping can be provided is not a handler method. * mapping can be provided is not a handler method.
*
* @param method the method to provide a mapping for * @param method the method to provide a mapping for
* @param handlerType the handler type, possibly a sub-type of the method's * @param handlerType the handler type, possibly a sub-type of the method's
* declaring class * declaring class
...@@ -168,7 +158,6 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap ...@@ -168,7 +158,6 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
/** /**
* Register a handler method and its unique mapping. * Register a handler method and its unique mapping.
*
* @param handler the bean name of the handler or the handler instance * @param handler the bean name of the handler or the handler instance
* @param method the method to register * @param method the method to register
* @param mapping the mapping conditions associated with the handler method * @param mapping the mapping conditions associated with the handler method
...@@ -192,7 +181,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap ...@@ -192,7 +181,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
+ oldHandlerMethod.getBean() + "' bean method\n" + oldHandlerMethod + " mapped."); + oldHandlerMethod.getBean() + "' bean method\n" + oldHandlerMethod + " mapped.");
} }
handlerMethods.put(mapping, handlerMethod); this.handlerMethods.put(mapping, handlerMethod);
if (logger.isInfoEnabled()) { if (logger.isInfoEnabled()) {
logger.info("Mapped \"" + mapping + "\" onto " + handlerMethod); logger.info("Mapped \"" + mapping + "\" onto " + handlerMethod);
} }
...@@ -200,7 +189,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap ...@@ -200,7 +189,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
Set<String> patterns = getMappingPathPatterns(mapping); Set<String> patterns = getMappingPathPatterns(mapping);
for (String pattern : patterns) { for (String pattern : patterns) {
if (!getPathMatcher().isPattern(pattern)) { if (!getPathMatcher().isPattern(pattern)) {
urlMap.add(pattern, mapping); this.urlMap.add(pattern, mapping);
} }
} }
} }
...@@ -237,11 +226,9 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap ...@@ -237,11 +226,9 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
/** /**
* Look up the best-matching handler method for the current request. * Look up the best-matching handler method for the current request.
* If multiple matches are found, the best match is selected. * If multiple matches are found, the best match is selected.
*
* @param lookupPath mapping lookup path within the current servlet mapping * @param lookupPath mapping lookup path within the current servlet mapping
* @param request the current request * @param request the current request
* @return the best-matching handler method, or {@code null} if no match * @return the best-matching handler method, or {@code null} if no match
*
* @see #handleMatch(Object, String, HttpServletRequest) * @see #handleMatch(Object, String, HttpServletRequest)
* @see #handleNoMatch(Set, String, HttpServletRequest) * @see #handleNoMatch(Set, String, HttpServletRequest)
*/ */
...@@ -298,7 +285,6 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap ...@@ -298,7 +285,6 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
/** /**
* Check if a mapping matches the current request and return a (potentially * Check if a mapping matches the current request and return a (potentially
* new) mapping with conditions relevant to the current request. * new) mapping with conditions relevant to the current request.
*
* @param mapping the mapping to get a match for * @param mapping the mapping to get a match for
* @param request the current HTTP servlet request * @param request the current HTTP servlet request
* @return the match, or {@code null} if the mapping doesn't match * @return the match, or {@code null} if the mapping doesn't match
...@@ -332,9 +318,11 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap ...@@ -332,9 +318,11 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
*/ */
protected HandlerMethod handleNoMatch(Set<T> mappings, String lookupPath, HttpServletRequest request) protected HandlerMethod handleNoMatch(Set<T> mappings, String lookupPath, HttpServletRequest request)
throws Exception { throws Exception {
return null; return null;
} }
/** /**
* A temporary container for a mapping matched to a request. * A temporary container for a mapping matched to a request.
*/ */
...@@ -351,10 +339,11 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap ...@@ -351,10 +339,11 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
@Override @Override
public String toString() { public String toString() {
return mapping.toString(); return this.mapping.toString();
} }
} }
private class MatchComparator implements Comparator<Match> { private class MatchComparator implements Comparator<Match> {
private final Comparator<T> comparator; private final Comparator<T> comparator;
...@@ -364,7 +353,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap ...@@ -364,7 +353,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
} }
public int compare(Match match1, Match match2) { public int compare(Match match1, Match match2) {
return comparator.compare(match1.mapping, match2.mapping); return this.comparator.compare(match1.mapping, match2.mapping);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册