类 AbstractHandlerMethodMapping<T>
- java.lang.Object
- org.springframework.context.support.ApplicationObjectSupport
- org.springframework.web.reactive.handler.AbstractHandlerMapping
- org.springframework.web.reactive.result.method.AbstractHandlerMethodMapping<T>
- 类型参数:
T
- the mapping for aHandlerMethod
containing the conditions needed to match the handler method to an incoming request.
public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMapping implements InitializingBean
Abstract base class forHandlerMapping
implementations that define a mapping between a request and aHandlerMethod
.For each registered handler method, a unique mapping is maintained with subclasses defining the details of the mapping type
<T>
.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Brian Clozel, Sam Brannen
字段概要
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
从接口继承的字段 org.springframework.web.reactive.HandlerMapping
BEST_MATCHING_HANDLER_ATTRIBUTE, BEST_MATCHING_PATTERN_ATTRIBUTE, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 AbstractHandlerMethodMapping()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Detects handler methods at initialization.protected HandlerMethod
createHandlerMethod(Object handler, Method method)
Create the HandlerMethod instance.protected void
detectHandlerMethods(Object handler)
Look for handler methods in a handler.protected CorsConfiguration
getCorsConfiguration(Object handler, ServerWebExchange exchange)
Retrieve the CORS configuration for the given handler.reactor.core.publisher.Mono<HandlerMethod>
getHandlerInternal(ServerWebExchange exchange)
Look up a handler method for the given request.Map<T,HandlerMethod>
getHandlerMethods()
Return a (read-only) map with all mappings and HandlerMethod's.protected abstract Comparator<T>
getMappingComparator(ServerWebExchange exchange)
Return a comparator for sorting matching mappings.protected abstract T
getMappingForMethod(Method method, Class<?> handlerType)
Provide the mapping for a handler method.protected abstract T
getMatchingMapping(T mapping, ServerWebExchange exchange)
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, HandlerMethod handlerMethod, ServerWebExchange exchange)
Invoked when a matching mapping is found.protected HandlerMethod
handleNoMatch(Set<T> mappings, ServerWebExchange exchange)
Invoked when no matching mapping is not found.protected void
handlerMethodsInitialized(Map<T,HandlerMethod> handlerMethods)
Invoked after all handler methods have been detected.protected boolean
hasCorsConfigurationSource(Object handler)
Returntrue
if there is aCorsConfigurationSource
for this handler.protected CorsConfiguration
initCorsConfiguration(Object handler, Method method, T mapping)
Extract and return the CORS configuration for the mapping.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(ServerWebExchange exchange)
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
registerMapping(T mapping, Object handler, Method method)
Register the given mapping.void
unregisterMapping(T mapping)
Un-register the given mapping.从类继承的方法 org.springframework.web.reactive.handler.AbstractHandlerMapping
formatMappingName, getCorsProcessor, getHandler, getOrder, getPathPatternParser, setBeanName, setCorsConfigurations, setCorsConfigurationSource, setCorsProcessor, setOrder, setUseCaseSensitiveMatch, setUseTrailingSlashMatch
从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext
构造器详细资料
AbstractHandlerMethodMapping
public AbstractHandlerMethodMapping()
方法详细资料
getHandlerMethods
public Map<T,HandlerMethod> getHandlerMethods()
Return a (read-only) map with all mappings and HandlerMethod's.
registerMapping
public void registerMapping(T mapping, Object handler, Method method)
Register the given mapping.This method may be invoked at runtime after initialization has completed.
- 参数:
mapping
- the mapping for the handler methodhandler
- the handlermethod
- the method
unregisterMapping
public void unregisterMapping(T mapping)
Un-register the given mapping.This method may be invoked at runtime after initialization has completed.
- 参数:
mapping
- the mapping to unregister
afterPropertiesSet
public void afterPropertiesSet()
Detects handler methods at initialization.- 指定者:
afterPropertiesSet
在接口中InitializingBean
initHandlerMethods
protected void initHandlerMethods()
Scan beans in the ApplicationContext, detect and register handler methods.
detectHandlerMethods
protected void detectHandlerMethods(Object handler)
Look for handler methods in a handler.- 参数:
handler
- the bean name of a handler or a handler instance
registerHandlerMethod
protected void registerHandlerMethod(Object handler, Method method, T mapping)
Register a handler method and its unique mapping. Invoked at startup for each detected handler method.- 参数:
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 mapping
createHandlerMethod
protected HandlerMethod createHandlerMethod(Object handler, Method method)
Create the HandlerMethod instance.- 参数:
handler
- either a bean name or an actual handler instancemethod
- the target method- 返回:
- the created HandlerMethod
initCorsConfiguration
@Nullable protected CorsConfiguration initCorsConfiguration(Object handler, Method method, T mapping)
Extract and return the CORS configuration for the mapping.
handlerMethodsInitialized
protected void handlerMethodsInitialized(Map<T,HandlerMethod> handlerMethods)
Invoked after all handler methods have been detected.- 参数:
handlerMethods
- a read-only map with handler methods and mappings.
getHandlerInternal
public reactor.core.publisher.Mono<HandlerMethod> getHandlerInternal(ServerWebExchange exchange)
Look up a handler method for the given request.- 指定者:
getHandlerInternal
在类中AbstractHandlerMapping
- 参数:
exchange
- the current exchange- 返回:
Mono
for the matching handler, if any
lookupHandlerMethod
@Nullable protected HandlerMethod lookupHandlerMethod(ServerWebExchange exchange) throws Exception
Look up the best-matching handler method for the current request. If multiple matches are found, the best match is selected.- 参数:
exchange
- the current exchange- 返回:
- the best-matching handler method, or
null
if no match - 抛出:
Exception
- 另请参阅:
handleMatch(T, org.springframework.web.method.HandlerMethod, org.springframework.web.server.ServerWebExchange)
,handleNoMatch(java.util.Set<T>, org.springframework.web.server.ServerWebExchange)
handleMatch
protected void handleMatch(T mapping, HandlerMethod handlerMethod, ServerWebExchange exchange)
Invoked when a matching mapping is found.- 参数:
mapping
- the matching mappinghandlerMethod
- the matching methodexchange
- the current exchange
handleNoMatch
@Nullable protected HandlerMethod handleNoMatch(Set<T> mappings, ServerWebExchange exchange) throws Exception
Invoked when no matching mapping is not found.- 参数:
mappings
- all registered mappingsexchange
- the current exchange- 返回:
- an alternative HandlerMethod or
null
- 抛出:
Exception
- provides details that can be translated into an error status code
hasCorsConfigurationSource
protected boolean hasCorsConfigurationSource(Object handler)
从类复制的说明:AbstractHandlerMapping
Returntrue
if there is aCorsConfigurationSource
for this handler.
getCorsConfiguration
protected CorsConfiguration getCorsConfiguration(Object handler, ServerWebExchange exchange)
从类复制的说明:AbstractHandlerMapping
Retrieve the CORS configuration for the given handler.- 覆盖:
getCorsConfiguration
在类中AbstractHandlerMapping
- 参数:
handler
- the handler to check (nevernull
)exchange
- the current exchange- 返回:
- the CORS configuration for the handler, or
null
if none
isHandler
protected abstract boolean isHandler(Class<?> beanType)
Whether the given type is a handler with handler methods.- 参数:
beanType
- the type of the bean being checked- 返回:
- "true" if this a handler type, "false" otherwise.
getMappingForMethod
@Nullable protected abstract T getMappingForMethod(Method method, Class<?> handlerType)
Provide the mapping for a handler method. A method for which no mapping can be provided is not a handler method.- 参数:
method
- the method to provide a mapping forhandlerType
- the handler type, possibly a sub-type of the method's declaring class- 返回:
- the mapping, or
null
if the method is not mapped
getMatchingMapping
@Nullable protected abstract T getMatchingMapping(T mapping, ServerWebExchange exchange)
Check if a mapping matches the current request and return a (potentially new) mapping with conditions relevant to the current request.- 参数:
mapping
- the mapping to get a match forexchange
- the current exchange- 返回:
- the match, or
null
if the mapping doesn't match
getMappingComparator
protected abstract Comparator<T> getMappingComparator(ServerWebExchange exchange)
Return a comparator for sorting matching mappings. The returned comparator should sort 'better' matches higher.- 参数:
exchange
- the current exchange- 返回:
- the comparator (never
null
)