|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.context.support.ApplicationObjectSupport org.springframework.web.context.support.WebApplicationObjectSupport org.springframework.web.servlet.handler.AbstractHandlerMapping org.springframework.web.servlet.handler.AbstractHandlerMethodMapping<T>
T
- The mapping for a HandlerMethod
containing the conditions
needed to match the handler method to incoming request.public abstract class AbstractHandlerMethodMapping<T>
Abstract base class for HandlerMapping
implementations that define a
mapping between a request and a HandlerMethod
.
For each registered handler method, a unique mapping is maintained with
subclasses defining the details of the mapping type <T>
.
Field Summary |
---|
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport |
---|
logger |
Fields inherited from interface org.springframework.web.servlet.HandlerMapping |
---|
BEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE |
Fields inherited from interface org.springframework.core.Ordered |
---|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
Constructor Summary | |
---|---|
AbstractHandlerMethodMapping()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
Detects handler methods at initialization. |
protected void |
detectHandlerMethods(Object handler)
Look for handler methods in a handler. |
protected HandlerMethod |
getHandlerInternal(HttpServletRequest request)
Look up a handler method for the given request. |
Map<T,HandlerMethod> |
getHandlerMethods()
Return a map with all handler methods and their mappings. |
protected abstract Comparator<T> |
getMappingComparator(HttpServletRequest request)
Return a comparator for sorting matching mappings. |
protected abstract T |
getMappingForMethod(Method method,
Class<?> handlerType)
Provide the mapping for a handler method. |
protected abstract Set<String> |
getMappingPathPatterns(T mapping)
Extract and return the URL paths contained in a mapping. |
protected abstract T |
getMatchingMapping(T mapping,
HttpServletRequest request)
Check if a mapping matches the current request and return a (potentially new) mapping with conditions relevant to the current request. |
protected void |
handleMatch(T mapping,
String lookupPath,
HttpServletRequest request)
Invoked when a matching mapping is found. |
protected HandlerMethod |
handleNoMatch(Set<T> mappings,
String lookupPath,
HttpServletRequest request)
Invoked when no matching mapping is not found. |
protected void |
handlerMethodsInitialized(Map<T,HandlerMethod> handlerMethods)
Invoked after all handler methods have been detected. |
protected void |
initHandlerMethods()
Scan beans in the ApplicationContext, detect and register handler methods. |
protected abstract boolean |
isHandler(Class<?> beanType)
Whether the given type is a handler with handler methods. |
protected HandlerMethod |
lookupHandlerMethod(String lookupPath,
HttpServletRequest request)
Look up the best-matching handler method for the current request. |
protected void |
registerHandlerMethod(Object handler,
Method method,
T mapping)
Register a handler method and its unique mapping. |
void |
setDetectHandlerMethodsInAncestorContexts(boolean detectHandlerMethodsInAncestorContexts)
Whether to detect handler methods in beans in ancestor ApplicationContexts. |
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping |
---|
adaptInterceptor, detectMappedInterceptors, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getUrlPathHelper, initApplicationContext, initInterceptors, setAlwaysUseFullPath, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setUrlDecode, setUrlPathHelper |
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 |
---|
public AbstractHandlerMethodMapping()
Method Detail |
---|
public void setDetectHandlerMethodsInAncestorContexts(boolean detectHandlerMethodsInAncestorContexts)
Default is "false": Only beans in the current ApplicationContext are considered, 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 Map<T,HandlerMethod> getHandlerMethods()
public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
protected void initHandlerMethods()
isHandler(Class)
,
getMappingForMethod(Method, Class)
,
handlerMethodsInitialized(Map)
protected abstract boolean isHandler(Class<?> beanType)
beanType
- the type of the bean being checked
protected void handlerMethodsInitialized(Map<T,HandlerMethod> handlerMethods)
handlerMethods
- a read-only map with handler methods and mappings.protected void detectHandlerMethods(Object handler)
handler
- the bean name of a handler or a handler instanceprotected abstract T getMappingForMethod(Method method, Class<?> handlerType)
method
- the method to provide a mapping forhandlerType
- the handler type, possibly a sub-type of the method's
declaring class
null
if the method is not mappedprotected void registerHandlerMethod(Object handler, Method method, T mapping)
handler
- the bean name of the handler or the handler instancemethod
- the method to registermapping
- the mapping conditions associated with the handler method
IllegalStateException
- if another method was already registered
under the same mappingprotected abstract Set<String> getMappingPathPatterns(T mapping)
protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception
getHandlerInternal
in class AbstractHandlerMapping
request
- current HTTP request
null
if none found
Exception
- if there is an internal errorprotected HandlerMethod lookupHandlerMethod(String lookupPath, HttpServletRequest request) throws Exception
lookupPath
- mapping lookup path within the current servlet mappingrequest
- the current request
null
if no match
Exception
handleMatch(Object, String, HttpServletRequest)
,
handleNoMatch(Set, String, HttpServletRequest)
protected abstract T getMatchingMapping(T mapping, HttpServletRequest request)
mapping
- the mapping to get a match forrequest
- the current HTTP servlet request
null
if the mapping doesn't matchprotected abstract Comparator<T> getMappingComparator(HttpServletRequest request)
request
- the current request
null
protected void handleMatch(T mapping, String lookupPath, HttpServletRequest request)
mapping
- the matching mappinglookupPath
- mapping lookup path within the current servlet mappingrequest
- the current requestprotected HandlerMethod handleNoMatch(Set<T> mappings, String lookupPath, HttpServletRequest request) throws Exception
mappings
- all registered mappingslookupPath
- mapping lookup path within the current servlet mappingrequest
- the current request
ServletException
- in case of errors
Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |