类 AbstractHandlerMapping
- 所有已实现的接口:
cn.taketoday.beans.factory.Aware,cn.taketoday.beans.factory.BeanNameAware,cn.taketoday.context.ApplicationContextAware,cn.taketoday.context.expression.EmbeddedValueResolverAware,cn.taketoday.core.Ordered,HandlerMapping
HandlerMapping
implementations. Supports ordering, a default handler, handler interceptors,
including handler interceptors mapped by path patterns.- 从以下版本开始:
- 2019-12-24 15:02
- 作者:
- Juergen Hoeller, Rossen Stoyanchev, Sam Brannen, Harry Yang
- 另请参阅:
-
嵌套类概要
嵌套类修饰符和类型类说明private classprivate class -
字段概要
字段修饰符和类型字段说明private Stringprivate CorsConfigurationSourceprivate CorsProcessorprivate Objectprotected cn.taketoday.core.StringValueResolverprivate final ArrayList<HandlerInterceptor>protected final cn.taketoday.logging.LoggerDedicated "hidden" logger for request mappings.private intprivate final PathPatternParser从类继承的字段 cn.taketoday.context.support.ApplicationObjectSupport
applicationContext, log, messageSourceAccessor从接口继承的字段 cn.taketoday.web.HandlerMapping
HANDLER_MAPPING_BEAN_NAME从接口继承的字段 cn.taketoday.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected voiddetectMappedInterceptors(List<HandlerInterceptor> mappedInterceptors) Detect beans of typeMappedInterceptorand add them to the list of mapped interceptors.protected voidextendInterceptors(List<HandlerInterceptor> interceptors) Extension hook that subclasses can override to register additional interceptors, given the configured interceptors (seesetInterceptors(java.lang.Object...)).protected Stringprotected CorsConfigurationgetCorsConfiguration(Object handler, RequestContext request) Retrieve the CORS configuration for the given handler.Return theconfiguredCorsConfigurationSource, if any.protected HandlerExecutionChaingetCorsHandlerExecutionChain(RequestContext request, HandlerExecutionChain chain, CorsConfiguration config) Update the HandlerExecutionChain for CORS-related handling.Return the configuredCorsProcessor.Return the default handler for this handler mapping, ornullif none.final ObjectgetHandler(RequestContext request) Look up a handler for the given request, falling back to the default handler if no specific one is found.protected HandlerExecutionChaingetHandlerExecutionChain(Object handler, RequestContext request) Build aHandlerExecutionChainfor the given handler, including applicable interceptors.protected HandlerInterceptor[]getHandlerInterceptors(Object handler) protected abstract ObjectgetHandlerInternal(RequestContext request) Look up a handler for the given request, returningnullif no specific one is found.intgetOrder()Return thePathPatternParserprotected booleanhasCorsConfigurationSource(Object handler) Returntrueif there is aCorsConfigurationSourcefor this handler.protected voidInitializes the interceptors.protected StringresolveEmbeddedVariables(String expression) voidsetBeanName(String name) voidsetCorsConfigurations(Map<String, CorsConfiguration> corsConfigurations) Set "global" CORS configuration mappings.voidSet aCorsConfigurationSourcefor "global" CORS config.voidsetCorsProcessor(CorsProcessor corsProcessor) Configure a customCorsProcessorto use to apply the matchedCorsConfigurationfor a request.voidsetDefaultHandler(Object defaultHandler) Set the default handler for this handler registry.voidsetEmbeddedValueResolver(cn.taketoday.core.StringValueResolver resolver) voidsetInterceptors(Object... interceptors) Set the interceptors to apply for all handlers mapped by this handler registry.voidsetOrder(int order) Specify the order value for this HandlerMapping bean.voidsetUseCaseSensitiveMatch(boolean caseSensitiveMatch) Shortcut method for setting the same property on the underlying pattern parser in use.voidsetUseTrailingSlashMatch(boolean trailingSlashMatch) Shortcut method for setting the same property on the underlying pattern parser in use.从类继承的方法 cn.taketoday.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext, unwrapContext, unwrapFactory
-
字段详细资料
-
mappingsLogger
protected final cn.taketoday.logging.Logger mappingsLoggerDedicated "hidden" logger for request mappings. -
defaultHandler
-
order
private int order -
beanName
-
embeddedValueResolver
@Nullable protected cn.taketoday.core.StringValueResolver embeddedValueResolver- 从以下版本开始:
- 4.0
-
patternParser
-
interceptors
-
corsConfigurationSource
-
corsProcessor
-
-
构造器详细资料
-
AbstractHandlerMapping
public AbstractHandlerMapping()
-
-
方法详细资料
-
setUseTrailingSlashMatch
public void setUseTrailingSlashMatch(boolean trailingSlashMatch) Shortcut method for setting the same property on the underlying pattern parser in use. For more details see:getPatternParser()-- the underlying pattern parserPathPatternParser.setMatchOptionalTrailingSeparator(boolean)-- the trailing slash option, including its default value.
-
setInterceptors
Set the interceptors to apply for all handlers mapped by this handler registry.- 参数:
interceptors- array of handler interceptors- 从以下版本开始:
- 4.0
-
setCorsConfigurations
Set "global" CORS configuration mappings. The first matching URL pattern determines theCorsConfigurationto use which is then furthercombinedwith theCorsConfigurationfor the selected handler.This is mutually exclusive with
setCorsConfigurationSource(CorsConfigurationSource).- 从以下版本开始:
- 4.0
- 另请参阅:
-
setCorsConfigurationSource
Set aCorsConfigurationSourcefor "global" CORS config. TheCorsConfigurationdetermined by the source iscombinedwith theCorsConfigurationfor the selected handler.This is mutually exclusive with
setCorsConfigurations(Map).- 从以下版本开始:
- 4.0
- 另请参阅:
-
setCorsProcessor
Configure a customCorsProcessorto use to apply the matchedCorsConfigurationfor a request.By default
DefaultCorsProcessoris used.- 从以下版本开始:
- 4.0
-
getCorsProcessor
Return the configuredCorsProcessor.- 从以下版本开始:
- 4.0
-
setOrder
public void setOrder(int order) Specify the order value for this HandlerMapping bean.The default value is
Ordered.LOWEST_PRECEDENCE, meaning non-ordered.- 另请参阅:
-
Ordered.getOrder()
-
getOrder
public int getOrder()- 指定者:
getOrder在接口中cn.taketoday.core.Ordered
-
setBeanName
- 指定者:
setBeanName在接口中cn.taketoday.beans.factory.BeanNameAware
-
formatMappingName
-
setEmbeddedValueResolver
public void setEmbeddedValueResolver(cn.taketoday.core.StringValueResolver resolver) - 指定者:
setEmbeddedValueResolver在接口中cn.taketoday.context.expression.EmbeddedValueResolverAware- 从以下版本开始:
- 4.0
-
resolveEmbeddedVariables
- 从以下版本开始:
- 3.0.3
-
getCorsConfigurationSource
Return theconfiguredCorsConfigurationSource, if any.- 从以下版本开始:
- 4.0
-
setDefaultHandler
Set the default handler for this handler registry. This handler will be returned if no specific mapping was found.Default is
null, indicating no default handler. -
getDefaultHandler
Return the default handler for this handler mapping, ornullif none. -
getPatternParser
Return thePathPatternParser- 从以下版本开始:
- 4.0
-
setUseCaseSensitiveMatch
public void setUseCaseSensitiveMatch(boolean caseSensitiveMatch) Shortcut method for setting the same property on the underlying pattern parser in use. For more details see:getPatternParser()-- the underlying pattern parserPathPatternParser.setCaseSensitive(boolean)-- the case sensitive slash option, including its default value.
Note: aside from
-
initApplicationContext
protected void initApplicationContext() throws cn.taketoday.beans.BeansExceptionInitializes the interceptors.- 覆盖:
initApplicationContext在类中cn.taketoday.context.support.ApplicationObjectSupport- 抛出:
cn.taketoday.beans.BeansException- 从以下版本开始:
- 4.0
- 另请参阅:
-
extendInterceptors
Extension hook that subclasses can override to register additional interceptors, given the configured interceptors (seesetInterceptors(java.lang.Object...)).The default implementation is empty.
- 参数:
interceptors- the configured interceptor List (nevernull), allowing to add further interceptors before as well as after the existing interceptors- 从以下版本开始:
- 4.0
-
detectMappedInterceptors
Detect beans of typeMappedInterceptorand add them to the list of mapped interceptors.This is called in addition to any
MappedInterceptors that may have been provided viasetInterceptors(java.lang.Object...), by default adding all beans of typeMappedInterceptorfrom the current context and its ancestors. Subclasses can override and refine this policy.- 参数:
mappedInterceptors- an empty list to add to- 从以下版本开始:
- 4.0
-
getHandler
Look up a handler for the given request, falling back to the default handler if no specific one is found.- 指定者:
getHandler在接口中HandlerMapping- 参数:
request- current HTTP request context- 返回:
- the corresponding handler instance, or the default handler
- 抛出:
Exception- if there is an internal error- 另请参阅:
-
getHandlerInternal
Look up a handler for the given request, returningnullif no specific one is found. This method is called bygetHandler(cn.taketoday.web.RequestContext); anullreturn value will lead to the default handler, if one is set.On CORS pre-flight requests this method should return a match not for the pre-flight request but for the expected actual request based on the URL path, the HTTP methods from the "Access-Control-Request-Method" header, and the headers from the "Access-Control-Request-Headers" header thus allowing the CORS configuration to be obtained via
getCorsConfiguration(Object, RequestContext),Note: This method may also return a pre-built
HandlerExecutionChain, combining a handler object with dynamically determined interceptors. Statically specified interceptors will get merged into such an existing chain.- 参数:
request- current HTTP request- 返回:
- the corresponding handler instance, or
nullif none found - 抛出:
Exception- if there is an internal error
-
getHandlerExecutionChain
Build aHandlerExecutionChainfor the given handler, including applicable interceptors.The default implementation builds a standard
HandlerExecutionChainwith the given handler, the common interceptors of the handler mapping, and anyMappedInterceptorsmatching to the current request URL. Interceptors are added in the order they were registered. Subclasses may override this in order to extend/rearrange the list of interceptors.NOTE: The passed-in handler object may be a raw handler or a pre-built
HandlerExecutionChain. This method should handle those two cases explicitly, either building a newHandlerExecutionChainor extending the existing chain.For simply adding an interceptor in a custom subclass, consider calling
super.getHandlerExecutionChain(handler, request)and invokingHandlerExecutionChain.addInterceptor(cn.taketoday.web.HandlerInterceptor)on the returned chain object.- 参数:
handler- the resolved handler instance (nevernull)request- current HTTP request- 返回:
- the HandlerExecutionChain (never
null) - 从以下版本开始:
- 4.0
-
getHandlerInterceptors
-
hasCorsConfigurationSource
Returntrueif there is aCorsConfigurationSourcefor this handler.- 从以下版本开始:
- 4.0
-
getCorsConfiguration
Retrieve the CORS configuration for the given handler.- 参数:
handler- the handler to check (nevernull).request- the current request.- 返回:
- the CORS configuration for the handler, or
nullif none - 从以下版本开始:
- 4.0
-
getCorsHandlerExecutionChain
protected HandlerExecutionChain getCorsHandlerExecutionChain(RequestContext request, HandlerExecutionChain chain, @Nullable CorsConfiguration config) Update the HandlerExecutionChain for CORS-related handling.For pre-flight requests, the default implementation replaces the selected handler with a simple HttpRequestHandler that invokes the configured
setCorsProcessor(cn.taketoday.web.cors.CorsProcessor).For actual requests, the default implementation inserts a HandlerInterceptor that makes CORS-related checks and adds CORS headers.
- 参数:
request- the current requestchain- the handler chainconfig- the applicable CORS configuration (possiblynull)- 从以下版本开始:
- 4.0
-