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 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.
|
buildPathExposingHandler, exposePathWithinMapping, exposeUriTemplateVariables, getHandlerInternal, getHandlerMap, getRootHandler, lookupHandler, registerHandler, registerHandler, setLazyInitHandlers, setRootHandler, setUseTrailingSlashMatch, supportsTypeLevelMappings, useTrailingSlashMatch, validateHandler
adaptInterceptor, detectMappedInterceptors, extendInterceptors, getAdaptedInterceptors, getCorsConfiguration, getCorsConfigurations, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getUrlPathHelper, initInterceptors, setAlwaysUseFullPath, setCorsConfigurations, setCorsProcessor, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
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)