类 ResourceUrlProvider

java.lang.Object
cn.taketoday.context.support.ApplicationObjectSupport
cn.taketoday.web.resource.ResourceUrlProvider
所有已实现的接口:
cn.taketoday.beans.factory.Aware, cn.taketoday.context.ApplicationContextAware, cn.taketoday.context.ApplicationListener<cn.taketoday.context.event.ContextRefreshedEvent>, EventListener

public class ResourceUrlProvider extends cn.taketoday.context.support.ApplicationObjectSupport implements cn.taketoday.context.ApplicationListener<cn.taketoday.context.event.ContextRefreshedEvent>, cn.taketoday.context.ApplicationContextAware
A central component to use to obtain the public URL path that clients should use to access a static resource.

This class is aware of Framework MVC handler mappings used to serve static resources and uses the ResourceResolver chains of the configured ResourceHttpRequestHandlers to make its decisions.

从以下版本开始:
4.0
作者:
Rossen Stoyanchev, Brian Clozel, Harry Yang
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    private boolean
     
     
    protected final cn.taketoday.logging.Logger
     
    private cn.taketoday.core.PathMatcher
     

    从类继承的字段 cn.taketoday.context.support.ApplicationObjectSupport

    applicationContext, log, messageSourceAccessor
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    protected void
    detectResourceHandlers(cn.taketoday.context.ApplicationContext appContext)
     
    private int
    getEndPathIndex(String lookupPath)
     
    final String
    Compare the given path against configured resource handler mappings and if a match is found use the ResourceResolver chain of the matched ResourceHttpRequestHandler to resolve the URL path to expose for public use.
    final String
    getForRequestUrl(RequestContext request, String requestUrl)
    A variation on getForLookupPath(String) that accepts a full request URL path (i.e. including context and servlet path) and returns the full request URL path to expose for public use.
    Return the resource mappings, either manually configured or auto-detected when the ApplicationContext is refreshed.
    private int
     
    cn.taketoday.core.PathMatcher
    Return the configured PathMatcher.
    boolean
    Return false if resource mappings were manually configured, true otherwise.
    void
    onApplicationEvent(cn.taketoday.context.event.ContextRefreshedEvent event)
     
    void
    Manually configure the resource mappings.
    void
    setPathMatcher(cn.taketoday.core.PathMatcher pathMatcher)
    Configure a PathMatcher to use when comparing target lookup path against resource mappings.

    从类继承的方法 cn.taketoday.context.support.ApplicationObjectSupport

    getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext, unwrapContext, unwrapFactory

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    从接口继承的方法 cn.taketoday.context.ApplicationContextAware

    setApplicationContext

    从接口继承的方法 cn.taketoday.context.ApplicationListener

    supportsAsyncExecution
  • 字段详细资料

    • logger

      protected final cn.taketoday.logging.Logger logger
    • pathMatcher

      private cn.taketoday.core.PathMatcher pathMatcher
    • handlerMap

      private final Map<String,ResourceHttpRequestHandler> handlerMap
    • autodetect

      private boolean autodetect
  • 构造器详细资料

    • ResourceUrlProvider

      public ResourceUrlProvider()
  • 方法详细资料

    • setPathMatcher

      public void setPathMatcher(cn.taketoday.core.PathMatcher pathMatcher)
      Configure a PathMatcher to use when comparing target lookup path against resource mappings.
    • getPathMatcher

      public cn.taketoday.core.PathMatcher getPathMatcher()
      Return the configured PathMatcher.
    • setHandlerMap

      public void setHandlerMap(@Nullable Map<String,ResourceHttpRequestHandler> handlerMap)
      Manually configure the resource mappings.

      Note: by default resource mappings are auto-detected from the ApplicationContext. However if this property is used, the auto-detection is turned off.

    • getHandlerMap

      public Map<String,ResourceHttpRequestHandler> getHandlerMap()
      Return the resource mappings, either manually configured or auto-detected when the ApplicationContext is refreshed.
    • isAutodetect

      public boolean isAutodetect()
      Return false if resource mappings were manually configured, true otherwise.
    • onApplicationEvent

      public void onApplicationEvent(cn.taketoday.context.event.ContextRefreshedEvent event)
      指定者:
      onApplicationEvent 在接口中 cn.taketoday.context.ApplicationListener<cn.taketoday.context.event.ContextRefreshedEvent>
    • detectResourceHandlers

      protected void detectResourceHandlers(cn.taketoday.context.ApplicationContext appContext)
    • getForRequestUrl

      @Nullable public final String getForRequestUrl(RequestContext request, String requestUrl)
      A variation on getForLookupPath(String) that accepts a full request URL path (i.e. including context and servlet path) and returns the full request URL path to expose for public use.
      参数:
      request - the current request
      requestUrl - the request URL path to resolve
      返回:
      the resolved public URL path, or null if unresolved
    • getLookupPathIndex

      private int getLookupPathIndex(RequestContext request)
    • getEndPathIndex

      private int getEndPathIndex(String lookupPath)
    • getForLookupPath

      @Nullable public final String getForLookupPath(String lookupPath)
      Compare the given path against configured resource handler mappings and if a match is found use the ResourceResolver chain of the matched ResourceHttpRequestHandler to resolve the URL path to expose for public use.

      It is expected that the given path is what MVC would use for request mapping purposes, i.e. excluding context and servlet path portions.

      If several handler mappings match, the handler used will be the one configured with the most specific pattern.

      参数:
      lookupPath - the lookup path to check
      返回:
      the resolved public URL path, or null if unresolved