The Spring Framework

org.springframework.web.servlet.handler
Class AbstractDetectingUrlHandlerMapping

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.handler.AbstractHandlerMapping
              extended by org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
                  extended by org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping
All Implemented Interfaces:
ApplicationContextAware, Ordered, ServletContextAware, HandlerMapping
Direct Known Subclasses:
AbstractControllerUrlHandlerMapping, BeanNameUrlHandlerMapping, DefaultAnnotationHandlerMapping

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.

Since:
2.5
Author:
Juergen Hoeller
See Also:
determineUrlsForHandler(java.lang.String)

Field Summary
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Fields inherited from interface org.springframework.web.servlet.HandlerMapping
PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
AbstractDetectingUrlHandlerMapping()
           
 
Method Summary
protected  void detectHandlers()
          Register all handlers found in the current ApplicationContext.
protected abstract  String[] determineUrlsForHandler(String beanName)
          Determine the URLs for the given handler bean.
 void initApplicationContext()
          Calls the detectHandlers() method in addition to the superclass's initialization.
 void setDetectHandlersInAncestorContexts(boolean detectHandlersInAncestorContexts)
          Set whether to detect handler beans in ancestor ApplicationContexts.
 
Methods inherited from class org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
buildPathExposingHandler, exposePathWithinMapping, getHandlerInternal, getHandlerMap, getPathMatcher, getRootHandler, lookupHandler, registerHandler, registerHandler, setAlwaysUseFullPath, setLazyInitHandlers, setPathMatcher, setRootHandler, setUrlDecode, setUrlPathHelper, validateHandler
 
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping
adaptInterceptor, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getOrder, initInterceptors, setDefaultHandler, setInterceptors, setOrder
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDetectingUrlHandlerMapping

public AbstractDetectingUrlHandlerMapping()
Method Detail

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.

Overrides:
initApplicationContext in class AbstractHandlerMapping
Throws:
ApplicationContextException - in case of initialization errors
See Also:
AbstractHandlerMapping.extendInterceptors(java.util.List), AbstractHandlerMapping.initInterceptors()

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.

Throws:
BeansException - if the handler couldn't be registered
See Also:
determineUrlsForHandler(String)

determineUrlsForHandler

protected abstract String[] determineUrlsForHandler(String beanName)
Determine the URLs for the given handler bean.

Parameters:
beanName - the name of the candidate bean
Returns:
the URLs determined for the bean, or null or an empty array if none

The Spring Framework

Copyright © 2002-2008 The Spring Framework.