Class ResourceTransformerSupport
- java.lang.Object
- org.springframework.web.servlet.resource.ResourceTransformerSupport
- All Implemented Interfaces:
ResourceTransformer
- Direct Known Subclasses:
AppCacheManifestTransformer
,CssLinkResourceTransformer
public abstract class ResourceTransformerSupport extends Object implements ResourceTransformer
A base class for aResourceTransformer
with an optional helper method for resolving public links within a transformed resource.- Since:
- 4.1
- Author:
- Brian Clozel, Rossen Stoyanchev
Constructor Summary
Constructors Constructor Description ResourceTransformerSupport()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourceUrlProvider
getResourceUrlProvider()
Return the configuredResourceUrlProvider
.protected String
resolveUrlPath(String resourcePath, HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain)
A transformer can use this method when a resource being transformed contains links to other resources.void
setResourceUrlProvider(ResourceUrlProvider resourceUrlProvider)
Configure aResourceUrlProvider
to use when resolving the public URL of links in a transformed resource (e.g.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.web.servlet.resource.ResourceTransformer
transform
Constructor Detail
ResourceTransformerSupport
public ResourceTransformerSupport()
Method Detail
setResourceUrlProvider
public void setResourceUrlProvider(ResourceUrlProvider resourceUrlProvider)
Configure aResourceUrlProvider
to use when resolving the public URL of links in a transformed resource (e.g. import links in a CSS file). This is required only for links expressed as full paths, i.e. including context and servlet path, and not for relative links.By default this property is not set. In that case if a
ResourceUrlProvider
is needed an attempt is made to find theResourceUrlProvider
exposed through theResourceUrlProviderExposingInterceptor
(configured by default in the MVC Java config and XML namespace). Therefore explicitly configuring this property should not be needed in most cases.- Parameters:
resourceUrlProvider
- the URL provider to use
getResourceUrlProvider
public ResourceUrlProvider getResourceUrlProvider()
Return the configuredResourceUrlProvider
.
resolveUrlPath
protected String resolveUrlPath(String resourcePath, HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain)
A transformer can use this method when a resource being transformed contains links to other resources. Such links need to be replaced with the public facing link as determined by the resource resolver chain (e.g. the public URL may have a version inserted).- Parameters:
resourcePath
- the path to a resource that needs to be re-writtenrequest
- the current requestresource
- the resource being transformedtransformerChain
- the transformer chain- Returns:
- the resolved URL, or if not resolvable