Class CachingResourceTransformer
- java.lang.Object
- org.springframework.web.servlet.resource.CachingResourceTransformer
- All Implemented Interfaces:
ResourceTransformer
public class CachingResourceTransformer extends Object implements ResourceTransformer
AResourceTransformer
that checks aCache
to see if a previously transformed resource exists in the cache and returns it if found, and otherwise delegates to the resolver chain and saves the result in the cache.- Since:
- 4.1
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Constructor Description CachingResourceTransformer(Cache cache)
CachingResourceTransformer(CacheManager cacheManager, String cacheName)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Cache
getCache()
Return the configuredCache
.Resource
transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain)
Transform the given resource.
Constructor Detail
CachingResourceTransformer
public CachingResourceTransformer(CacheManager cacheManager, String cacheName)
CachingResourceTransformer
public CachingResourceTransformer(Cache cache)
Method Detail
transform
public Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) throws IOException
Description copied from interface:ResourceTransformer
Transform the given resource.- Specified by:
transform
in interfaceResourceTransformer
- Parameters:
request
- the current requestresource
- the resource to transformtransformerChain
- the chain of remaining transformers to delegate to- Returns:
- the transformed resource (never
null
) - Throws:
IOException
- if the transformation fails