25
25
import java .util .List ;
26
26
import java .util .Map ;
27
27
import java .util .Set ;
28
-
29
28
import javax .servlet .ServletException ;
30
29
import javax .servlet .http .HttpServletRequest ;
31
30
32
31
import org .springframework .beans .factory .BeanFactoryUtils ;
33
32
import org .springframework .beans .factory .InitializingBean ;
34
- import org .springframework .context .ApplicationContextException ;
35
33
import org .springframework .util .ClassUtils ;
36
34
import org .springframework .util .LinkedMultiValueMap ;
37
35
import org .springframework .util .MultiValueMap ;
@@ -62,6 +60,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
62
60
63
61
private final MultiValueMap <String , T > urlMap = new LinkedMultiValueMap <String , T >();
64
62
63
+
65
64
/**
66
65
* Whether to detect handler methods in beans in ancestor ApplicationContexts.
67
66
* <p>Default is "false": Only beans in the current ApplicationContext are
@@ -78,15 +77,7 @@ public void setDetectHandlerMethodsInAncestorContexts(boolean detectHandlerMetho
78
77
* Return a map with all handler methods and their mappings.
79
78
*/
80
79
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 );
90
81
}
91
82
92
83
/**
@@ -158,7 +149,6 @@ public boolean matches(Method method) {
158
149
/**
159
150
* Provide the mapping for a handler method. A method for which no
160
151
* mapping can be provided is not a handler method.
161
- *
162
152
* @param method the method to provide a mapping for
163
153
* @param handlerType the handler type, possibly a sub-type of the method's
164
154
* declaring class
@@ -168,7 +158,6 @@ public boolean matches(Method method) {
168
158
169
159
/**
170
160
* Register a handler method and its unique mapping.
171
- *
172
161
* @param handler the bean name of the handler or the handler instance
173
162
* @param method the method to register
174
163
* @param mapping the mapping conditions associated with the handler method
@@ -192,15 +181,15 @@ protected void registerHandlerMethod(Object handler, Method method, T mapping) {
192
181
+ oldHandlerMethod .getBean () + "' bean method\n " + oldHandlerMethod + " mapped." );
193
182
}
194
183
195
- handlerMethods .put (mapping , handlerMethod );
184
+ this . handlerMethods .put (mapping , handlerMethod );
196
185
if (logger .isInfoEnabled ()) {
197
186
logger .info ("Mapped \" " + mapping + "\" onto " + handlerMethod );
198
187
}
199
188
200
189
Set <String > patterns = getMappingPathPatterns (mapping );
201
190
for (String pattern : patterns ) {
202
191
if (!getPathMatcher ().isPattern (pattern )) {
203
- urlMap .add (pattern , mapping );
192
+ this . urlMap .add (pattern , mapping );
204
193
}
205
194
}
206
195
}
@@ -237,11 +226,9 @@ protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Ex
237
226
/**
238
227
* Look up the best-matching handler method for the current request.
239
228
* If multiple matches are found, the best match is selected.
240
- *
241
229
* @param lookupPath mapping lookup path within the current servlet mapping
242
230
* @param request the current request
243
231
* @return the best-matching handler method, or {@code null} if no match
244
- *
245
232
* @see #handleMatch(Object, String, HttpServletRequest)
246
233
* @see #handleNoMatch(Set, String, HttpServletRequest)
247
234
*/
@@ -298,7 +285,6 @@ private void addMatchingMappings(Collection<T> mappings, List<Match> matches, Ht
298
285
/**
299
286
* Check if a mapping matches the current request and return a (potentially
300
287
* new) mapping with conditions relevant to the current request.
301
- *
302
288
* @param mapping the mapping to get a match for
303
289
* @param request the current HTTP servlet request
304
290
* @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
332
318
*/
333
319
protected HandlerMethod handleNoMatch (Set <T > mappings , String lookupPath , HttpServletRequest request )
334
320
throws Exception {
321
+
335
322
return null ;
336
323
}
337
324
325
+
338
326
/**
339
327
* A temporary container for a mapping matched to a request.
340
328
*/
@@ -351,10 +339,11 @@ private Match(T mapping, HandlerMethod handlerMethod) {
351
339
352
340
@ Override
353
341
public String toString () {
354
- return mapping .toString ();
342
+ return this . mapping .toString ();
355
343
}
356
344
}
357
345
346
+
358
347
private class MatchComparator implements Comparator <Match > {
359
348
360
349
private final Comparator <T > comparator ;
@@ -364,8 +353,8 @@ public MatchComparator(Comparator<T> comparator) {
364
353
}
365
354
366
355
public int compare (Match match1 , Match match2 ) {
367
- return comparator .compare (match1 .mapping , match2 .mapping );
356
+ return this . comparator .compare (match1 .mapping , match2 .mapping );
368
357
}
369
358
}
370
359
371
- }
360
+ }
0 commit comments