public abstract class AbstractDetectingUrlHandlerMapping extends AbstractUrlHandlerMapping
HandlerMapping
interface, detecting URL mappings for handler beans through introspection of all
defined beans in the application context.determineUrlsForHandler(java.lang.String)
logger
BEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
AbstractDetectingUrlHandlerMapping() |
Modifier and Type | Method and Description |
---|---|
protected void |
detectHandlers()
Register all handlers found in the current ApplicationContext.
|
protected abstract java.lang.String[] |
determineUrlsForHandler(java.lang.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.
|
buildPathExposingHandler, exposePathWithinMapping, exposeUriTemplateVariables, getHandlerInternal, getHandlerMap, getRootHandler, lookupHandler, match, registerHandler, registerHandler, setLazyInitHandlers, setRootHandler, setUseTrailingSlashMatch, supportsTypeLevelMappings, useTrailingSlashMatch, validateHandler
adaptInterceptor, detectMappedInterceptors, extendInterceptors, formatMappingName, getAdaptedInterceptors, getCorsConfiguration, getCorsConfigurations, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getUrlPathHelper, initInterceptors, setAlwaysUseFullPath, setBeanName, setCorsConfigurations, setCorsConfigurationSource, setCorsProcessor, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, obtainApplicationContext, requiredContextClass, setApplicationContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getHandler
public void setDetectHandlersInAncestorContexts(boolean detectHandlersInAncestorContexts)
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.
public void initApplicationContext() throws ApplicationContextException
detectHandlers()
method in addition to the
superclass's initialization.initApplicationContext
in class AbstractHandlerMapping
ApplicationContextException
- in case of initialization errorsAbstractHandlerMapping.extendInterceptors(java.util.List)
,
AbstractHandlerMapping.initInterceptors()
protected void detectHandlers() throws BeansException
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 registereddetermineUrlsForHandler(String)
protected abstract java.lang.String[] determineUrlsForHandler(java.lang.String beanName)
beanName
- the name of the candidate bean