类 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 booleanprivate final Map<String,ResourceHttpRequestHandler> protected final cn.taketoday.logging.Loggerprivate cn.taketoday.core.PathMatcher从类继承的字段 cn.taketoday.context.support.ApplicationObjectSupport
applicationContext, log, messageSourceAccessor -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected voiddetectResourceHandlers(cn.taketoday.context.ApplicationContext appContext) private intgetEndPathIndex(String lookupPath) final StringgetForLookupPath(String lookupPath) Compare the given path against configured resource handler mappings and if a match is found use theResourceResolverchain of the matchedResourceHttpRequestHandlerto resolve the URL path to expose for public use.final StringgetForRequestUrl(RequestContext request, String requestUrl) A variation ongetForLookupPath(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 theApplicationContextis refreshed.private intgetLookupPathIndex(RequestContext request) cn.taketoday.core.PathMatcherReturn the configuredPathMatcher.booleanReturnfalseif resource mappings were manually configured,trueotherwise.voidonApplicationEvent(cn.taketoday.context.event.ContextRefreshedEvent event) voidsetHandlerMap(Map<String, ResourceHttpRequestHandler> handlerMap) Manually configure the resource mappings.voidsetPathMatcher(cn.taketoday.core.PathMatcher pathMatcher) Configure aPathMatcherto 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
-
autodetect
private boolean autodetect
-
-
构造器详细资料
-
ResourceUrlProvider
public ResourceUrlProvider()
-
-
方法详细资料
-
setPathMatcher
public void setPathMatcher(cn.taketoday.core.PathMatcher pathMatcher) Configure aPathMatcherto use when comparing target lookup path against resource mappings. -
getPathMatcher
public cn.taketoday.core.PathMatcher getPathMatcher()Return the configuredPathMatcher. -
setHandlerMap
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
Return the resource mappings, either manually configured or auto-detected when theApplicationContextis refreshed. -
isAutodetect
public boolean isAutodetect()Returnfalseif resource mappings were manually configured,trueotherwise. -
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
A variation ongetForLookupPath(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 requestrequestUrl- the request URL path to resolve- 返回:
- the resolved public URL path, or
nullif unresolved
-
getLookupPathIndex
-
getEndPathIndex
-
getForLookupPath
Compare the given path against configured resource handler mappings and if a match is found use theResourceResolverchain of the matchedResourceHttpRequestHandlerto 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
nullif unresolved
-