Class AbstractDetectingUrlHandlerMapping

All Implemented Interfaces:
Aware, BeanNameAware, ApplicationContextAware, Ordered, ServletContextAware, MatchableHandlerMapping, HandlerMapping
Direct Known Subclasses:

public abstract class AbstractDetectingUrlHandlerMapping extends AbstractUrlHandlerMapping
Abstract implementation of the HandlerMapping interface, detecting URL mappings for handler beans through introspection of all defined beans in the application context.
Juergen Hoeller
See Also:
  • Constructor Details

    • AbstractDetectingUrlHandlerMapping

      public AbstractDetectingUrlHandlerMapping()
  • Method Details

    • setDetectHandlersInAncestorContexts

      public void setDetectHandlersInAncestorContexts(boolean detectHandlersInAncestorContexts)
      Set whether to detect handler beans in ancestor ApplicationContexts.

      Default is "false": Only handler beans in the current ApplicationContext will be detected, i.e. only in the context that this HandlerMapping itself is defined in (typically the current DispatcherServlet's context).

      Switch this flag on to detect handler beans in ancestor contexts (typically the Spring root WebApplicationContext) as well.

    • initApplicationContext

      public void initApplicationContext() throws ApplicationContextException
      Calls the detectHandlers() method in addition to the superclass's initialization.
      initApplicationContext in class AbstractHandlerMapping
      ApplicationContextException - in case of initialization errors
      See Also:
    • detectHandlers

      protected void detectHandlers() throws BeansException
      Register all handlers found in the current ApplicationContext.

      The actual URL determination for a handler is up to the concrete determineUrlsForHandler(String) implementation. A bean for which no such URLs could be determined is simply not considered a handler.

      BeansException - if the handler couldn't be registered
      See Also:
    • determineUrlsForHandler

      protected abstract String[] determineUrlsForHandler(String beanName)
      Determine the URLs for the given handler bean.
      beanName - the name of the candidate bean
      the URLs determined for the bean, or an empty array if none