Skip to content

Commit d97a4b5

Browse files
committed
polishing
1 parent 5965710 commit d97a4b5

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@
2525
import java.util.List;
2626
import java.util.Map;
2727
import java.util.Set;
28-
2928
import javax.servlet.ServletException;
3029
import javax.servlet.http.HttpServletRequest;
3130

3231
import org.springframework.beans.factory.BeanFactoryUtils;
3332
import org.springframework.beans.factory.InitializingBean;
34-
import org.springframework.context.ApplicationContextException;
3533
import org.springframework.util.ClassUtils;
3634
import org.springframework.util.LinkedMultiValueMap;
3735
import org.springframework.util.MultiValueMap;
@@ -62,6 +60,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
6260

6361
private final MultiValueMap<String, T> urlMap = new LinkedMultiValueMap<String, T>();
6462

63+
6564
/**
6665
* Whether to detect handler methods in beans in ancestor ApplicationContexts.
6766
* <p>Default is "false": Only beans in the current ApplicationContext are
@@ -78,15 +77,7 @@ public void setDetectHandlerMethodsInAncestorContexts(boolean detectHandlerMetho
7877
* Return a map with all handler methods and their mappings.
7978
*/
8079
public Map<T, HandlerMethod> getHandlerMethods() {
81-
return Collections.unmodifiableMap(handlerMethods);
82-
}
83-
84-
/**
85-
* ApplicationContext initialization.
86-
*/
87-
@Override
88-
public void initApplicationContext() throws ApplicationContextException {
89-
super.initApplicationContext();
80+
return Collections.unmodifiableMap(this.handlerMethods);
9081
}
9182

9283
/**
@@ -158,7 +149,6 @@ public boolean matches(Method method) {
158149
/**
159150
* Provide the mapping for a handler method. A method for which no
160151
* mapping can be provided is not a handler method.
161-
*
162152
* @param method the method to provide a mapping for
163153
* @param handlerType the handler type, possibly a sub-type of the method's
164154
* declaring class
@@ -168,7 +158,6 @@ public boolean matches(Method method) {
168158

169159
/**
170160
* Register a handler method and its unique mapping.
171-
*
172161
* @param handler the bean name of the handler or the handler instance
173162
* @param method the method to register
174163
* @param mapping the mapping conditions associated with the handler method
@@ -192,15 +181,15 @@ protected void registerHandlerMethod(Object handler, Method method, T mapping) {
192181
+ oldHandlerMethod.getBean() + "' bean method\n" + oldHandlerMethod + " mapped.");
193182
}
194183

195-
handlerMethods.put(mapping, handlerMethod);
184+
this.handlerMethods.put(mapping, handlerMethod);
196185
if (logger.isInfoEnabled()) {
197186
logger.info("Mapped \"" + mapping + "\" onto " + handlerMethod);
198187
}
199188

200189
Set<String> patterns = getMappingPathPatterns(mapping);
201190
for (String pattern : patterns) {
202191
if (!getPathMatcher().isPattern(pattern)) {
203-
urlMap.add(pattern, mapping);
192+
this.urlMap.add(pattern, mapping);
204193
}
205194
}
206195
}
@@ -237,11 +226,9 @@ protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Ex
237226
/**
238227
* Look up the best-matching handler method for the current request.
239228
* If multiple matches are found, the best match is selected.
240-
*
241229
* @param lookupPath mapping lookup path within the current servlet mapping
242230
* @param request the current request
243231
* @return the best-matching handler method, or {@code null} if no match
244-
*
245232
* @see #handleMatch(Object, String, HttpServletRequest)
246233
* @see #handleNoMatch(Set, String, HttpServletRequest)
247234
*/
@@ -298,7 +285,6 @@ private void addMatchingMappings(Collection<T> mappings, List<Match> matches, Ht
298285
/**
299286
* Check if a mapping matches the current request and return a (potentially
300287
* new) mapping with conditions relevant to the current request.
301-
*
302288
* @param mapping the mapping to get a match for
303289
* @param request the current HTTP servlet request
304290
* @return the match, or {@code null} if the mapping doesn't match
@@ -332,9 +318,11 @@ protected void handleMatch(T mapping, String lookupPath, HttpServletRequest requ
332318
*/
333319
protected HandlerMethod handleNoMatch(Set<T> mappings, String lookupPath, HttpServletRequest request)
334320
throws Exception {
321+
335322
return null;
336323
}
337324

325+
338326
/**
339327
* A temporary container for a mapping matched to a request.
340328
*/
@@ -351,10 +339,11 @@ private Match(T mapping, HandlerMethod handlerMethod) {
351339

352340
@Override
353341
public String toString() {
354-
return mapping.toString();
342+
return this.mapping.toString();
355343
}
356344
}
357345

346+
358347
private class MatchComparator implements Comparator<Match> {
359348

360349
private final Comparator<T> comparator;
@@ -364,8 +353,8 @@ public MatchComparator(Comparator<T> comparator) {
364353
}
365354

366355
public int compare(Match match1, Match match2) {
367-
return comparator.compare(match1.mapping, match2.mapping);
356+
return this.comparator.compare(match1.mapping, match2.mapping);
368357
}
369358
}
370359

371-
}
360+
}

0 commit comments

Comments
 (0)