类 AbstractHandlerMapping

java.lang.Object
cn.taketoday.context.support.ApplicationObjectSupport
cn.taketoday.web.handler.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
直接已知子类:
AbstractHandlerMethodMapping, AbstractUrlHandlerMapping, RouterFunctionMapping

public abstract class AbstractHandlerMapping extends cn.taketoday.context.support.ApplicationObjectSupport implements HandlerMapping, cn.taketoday.core.Ordered, cn.taketoday.context.expression.EmbeddedValueResolverAware, cn.taketoday.beans.factory.BeanNameAware
Abstract base class for 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
另请参阅:
  • 字段详细资料

    • mappingsLogger

      protected final cn.taketoday.logging.Logger mappingsLogger
      Dedicated "hidden" logger for request mappings.
    • defaultHandler

      @Nullable private Object defaultHandler
    • order

      private int order
    • beanName

      @Nullable private String beanName
    • embeddedValueResolver

      @Nullable protected cn.taketoday.core.StringValueResolver embeddedValueResolver
      从以下版本开始:
      4.0
    • patternParser

      private final PathPatternParser patternParser
    • interceptors

      private final ArrayList<HandlerInterceptor> interceptors
    • corsConfigurationSource

      @Nullable private CorsConfigurationSource corsConfigurationSource
    • corsProcessor

      private CorsProcessor 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:
    • setInterceptors

      public void setInterceptors(Object... interceptors)
      Set the interceptors to apply for all handlers mapped by this handler registry.
      参数:
      interceptors - array of handler interceptors
      从以下版本开始:
      4.0
    • setCorsConfigurations

      public void setCorsConfigurations(Map<String,CorsConfiguration> corsConfigurations)
      Set "global" CORS configuration mappings. The first matching URL pattern determines the CorsConfiguration to use which is then further combined with the CorsConfiguration for the selected handler.

      This is mutually exclusive with setCorsConfigurationSource(CorsConfigurationSource).

      从以下版本开始:
      4.0
      另请参阅:
    • setCorsConfigurationSource

      public void setCorsConfigurationSource(CorsConfigurationSource source)
      Set a CorsConfigurationSource for "global" CORS config. The CorsConfiguration determined by the source is combined with the CorsConfiguration for the selected handler.

      This is mutually exclusive with setCorsConfigurations(Map).

      从以下版本开始:
      4.0
      另请参阅:
    • setCorsProcessor

      public void setCorsProcessor(CorsProcessor corsProcessor)
      Configure a custom CorsProcessor to use to apply the matched CorsConfiguration for a request.

      By default DefaultCorsProcessor is used.

      从以下版本开始:
      4.0
    • getCorsProcessor

      public CorsProcessor getCorsProcessor()
      Return the configured CorsProcessor.
      从以下版本开始:
      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

      public void setBeanName(String name)
      指定者:
      setBeanName 在接口中 cn.taketoday.beans.factory.BeanNameAware
    • formatMappingName

      protected String formatMappingName()
    • setEmbeddedValueResolver

      public void setEmbeddedValueResolver(cn.taketoday.core.StringValueResolver resolver)
      指定者:
      setEmbeddedValueResolver 在接口中 cn.taketoday.context.expression.EmbeddedValueResolverAware
      从以下版本开始:
      4.0
    • resolveEmbeddedVariables

      @Nullable protected String resolveEmbeddedVariables(String expression)
      从以下版本开始:
      3.0.3
    • getCorsConfigurationSource

      @Nullable public CorsConfigurationSource getCorsConfigurationSource()
      Return the configured CorsConfigurationSource, if any.
      从以下版本开始:
      4.0
    • setDefaultHandler

      public void setDefaultHandler(@Nullable Object defaultHandler)
      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

      @Nullable public Object getDefaultHandler()
      Return the default handler for this handler mapping, or null if none.
    • getPatternParser

      public PathPatternParser getPatternParser()
      从以下版本开始:
      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:

      Note: aside from

    • initApplicationContext

      protected void initApplicationContext() throws cn.taketoday.beans.BeansException
      Initializes the interceptors.
      覆盖:
      initApplicationContext 在类中 cn.taketoday.context.support.ApplicationObjectSupport
      抛出:
      cn.taketoday.beans.BeansException
      从以下版本开始:
      4.0
      另请参阅:
    • extendInterceptors

      protected void extendInterceptors(List<HandlerInterceptor> interceptors)
      Extension hook that subclasses can override to register additional interceptors, given the configured interceptors (see setInterceptors(java.lang.Object...)).

      The default implementation is empty.

      参数:
      interceptors - the configured interceptor List (never null), allowing to add further interceptors before as well as after the existing interceptors
      从以下版本开始:
      4.0
    • detectMappedInterceptors

      protected void detectMappedInterceptors(List<HandlerInterceptor> mappedInterceptors)
      Detect beans of type MappedInterceptor and add them to the list of mapped interceptors.

      This is called in addition to any MappedInterceptors that may have been provided via setInterceptors(java.lang.Object...), by default adding all beans of type MappedInterceptor from the current context and its ancestors. Subclasses can override and refine this policy.

      参数:
      mappedInterceptors - an empty list to add to
      从以下版本开始:
      4.0
    • getHandler

      @Nullable public final Object getHandler(RequestContext request) throws Exception
      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

      @Nullable protected abstract Object getHandlerInternal(RequestContext request) throws Exception
      Look up a handler for the given request, returning null if no specific one is found. This method is called by getHandler(cn.taketoday.web.RequestContext); a null return 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 null if none found
      抛出:
      Exception - if there is an internal error
    • getHandlerExecutionChain

      protected HandlerExecutionChain getHandlerExecutionChain(Object handler, RequestContext request)
      Build a HandlerExecutionChain for the given handler, including applicable interceptors.

      The default implementation builds a standard HandlerExecutionChain with the given handler, the common interceptors of the handler mapping, and any MappedInterceptors matching 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 new HandlerExecutionChain or extending the existing chain.

      For simply adding an interceptor in a custom subclass, consider calling super.getHandlerExecutionChain(handler, request) and invoking HandlerExecutionChain.addInterceptor(cn.taketoday.web.HandlerInterceptor) on the returned chain object.

      参数:
      handler - the resolved handler instance (never null)
      request - current HTTP request
      返回:
      the HandlerExecutionChain (never null)
      从以下版本开始:
      4.0
    • getHandlerInterceptors

      @Nullable protected HandlerInterceptor[] getHandlerInterceptors(Object handler)
    • hasCorsConfigurationSource

      protected boolean hasCorsConfigurationSource(Object handler)
      Return true if there is a CorsConfigurationSource for this handler.
      从以下版本开始:
      4.0
    • getCorsConfiguration

      @Nullable protected CorsConfiguration getCorsConfiguration(Object handler, RequestContext request)
      Retrieve the CORS configuration for the given handler.
      参数:
      handler - the handler to check (never null).
      request - the current request.
      返回:
      the CORS configuration for the handler, or null if 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 request
      chain - the handler chain
      config - the applicable CORS configuration (possibly null)
      从以下版本开始:
      4.0