@@ -153,6 +153,28 @@ MappingRegistry getMappingRegistry() {
153153 return this .mappingRegistry ;
154154 }
155155
156+ /**
157+ * Register the given mapping.
158+ * <p>This method may be invoked at runtime after initialization has completed.
159+ * @param mapping the mapping for the handler method
160+ * @param handler the handler
161+ * @param method the method
162+ */
163+ public void registerMapping (T mapping , Object handler , Method method ) {
164+ this .mappingRegistry .register (mapping , handler , method );
165+ }
166+
167+ /**
168+ * Un-register the given mapping.
169+ * <p>This method may be invoked at runtime after initialization has completed.
170+ * @param mapping the mapping to unregister
171+ */
172+ public void unregisterMapping (T mapping ) {
173+ this .mappingRegistry .unregister (mapping );
174+ }
175+
176+
177+ // Handler method detection
156178
157179 /**
158180 * Detects handler methods at initialization.
@@ -196,13 +218,6 @@ protected void initHandlerMethods() {
196218 handlerMethodsInitialized (getHandlerMethods ());
197219 }
198220
199- /**
200- * Whether the given type is a handler with handler methods.
201- * @param beanType the type of the bean being checked
202- * @return "true" if this a handler type, "false" otherwise.
203- */
204- protected abstract boolean isHandler (Class <?> beanType );
205-
206221 /**
207222 * Look for handler methods in a handler.
208223 * @param handler the bean name of a handler or a handler instance
@@ -230,16 +245,6 @@ public T inspect(Method method) {
230245 }
231246 }
232247
233- /**
234- * Provide the mapping for a handler method. A method for which no
235- * mapping can be provided is not a handler method.
236- * @param method the method to provide a mapping for
237- * @param handlerType the handler type, possibly a sub-type of the method's
238- * declaring class
239- * @return the mapping, or {@code null} if the method is not mapped
240- */
241- protected abstract T getMappingForMethod (Method method , Class <?> handlerType );
242-
243248 /**
244249 * Register a handler method and its unique mapping. Invoked at startup for
245250 * each detected handler method.
@@ -272,11 +277,6 @@ protected HandlerMethod createHandlerMethod(Object handler, Method method) {
272277 return handlerMethod ;
273278 }
274279
275- /**
276- * Extract and return the URL paths contained in a mapping.
277- */
278- protected abstract Set <String > getMappingPathPatterns (T mapping );
279-
280280 /**
281281 * Extract and return the CORS configuration for the mapping.
282282 */
@@ -291,25 +291,8 @@ protected CorsConfiguration initCorsConfiguration(Object handler, Method method,
291291 protected void handlerMethodsInitialized (Map <T , HandlerMethod > handlerMethods ) {
292292 }
293293
294- /**
295- * Register the given mapping.
296- * <p>This method may be invoked at runtime after initialization has completed.
297- * @param mapping the mapping for the handler method
298- * @param handler the handler
299- * @param method the method
300- */
301- public void registerMapping (T mapping , Object handler , Method method ) {
302- this .mappingRegistry .register (mapping , handler , method );
303- }
304294
305- /**
306- * Un-register the given mapping.
307- * <p>This method may be invoked at runtime after initialization has completed.
308- * @param mapping the mapping to unregister
309- */
310- public void unregisterMapping (T mapping ) {
311- this .mappingRegistry .unregister (mapping );
312- }
295+ // Handler method lookup
313296
314297 /**
315298 * Look up a handler method for the given request.
@@ -395,23 +378,6 @@ private void addMatchingMappings(Collection<T> mappings, List<Match> matches, Ht
395378 }
396379 }
397380
398- /**
399- * Check if a mapping matches the current request and return a (potentially
400- * new) mapping with conditions relevant to the current request.
401- * @param mapping the mapping to get a match for
402- * @param request the current HTTP servlet request
403- * @return the match, or {@code null} if the mapping doesn't match
404- */
405- protected abstract T getMatchingMapping (T mapping , HttpServletRequest request );
406-
407- /**
408- * Return a comparator for sorting matching mappings.
409- * The returned comparator should sort 'better' matches higher.
410- * @param request the current request
411- * @return the comparator (never {@code null})
412- */
413- protected abstract Comparator <T > getMappingComparator (HttpServletRequest request );
414-
415381 /**
416382 * Invoked when a matching mapping is found.
417383 * @param mapping the matching mapping
@@ -452,6 +418,48 @@ protected CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequ
452418 }
453419
454420
421+ // Abstract template methods
422+
423+ /**
424+ * Whether the given type is a handler with handler methods.
425+ * @param beanType the type of the bean being checked
426+ * @return "true" if this a handler type, "false" otherwise.
427+ */
428+ protected abstract boolean isHandler (Class <?> beanType );
429+
430+ /**
431+ * Provide the mapping for a handler method. A method for which no
432+ * mapping can be provided is not a handler method.
433+ * @param method the method to provide a mapping for
434+ * @param handlerType the handler type, possibly a sub-type of the method's
435+ * declaring class
436+ * @return the mapping, or {@code null} if the method is not mapped
437+ */
438+ protected abstract T getMappingForMethod (Method method , Class <?> handlerType );
439+
440+ /**
441+ * Extract and return the URL paths contained in a mapping.
442+ */
443+ protected abstract Set <String > getMappingPathPatterns (T mapping );
444+
445+ /**
446+ * Check if a mapping matches the current request and return a (potentially
447+ * new) mapping with conditions relevant to the current request.
448+ * @param mapping the mapping to get a match for
449+ * @param request the current HTTP servlet request
450+ * @return the match, or {@code null} if the mapping doesn't match
451+ */
452+ protected abstract T getMatchingMapping (T mapping , HttpServletRequest request );
453+
454+ /**
455+ * Return a comparator for sorting matching mappings.
456+ * The returned comparator should sort 'better' matches higher.
457+ * @param request the current request
458+ * @return the comparator (never {@code null})
459+ */
460+ protected abstract Comparator <T > getMappingComparator (HttpServletRequest request );
461+
462+
455463 /**
456464 * A registry that maintains all mappings to handler methods, exposing methods
457465 * to perform lookups and providing concurrent access.
0 commit comments