Top Description Fields Constructors Methods
org.springframework.web.servlet.resource

public Class CachingResourceTransformer

extends Object
implements ResourceTransformer
Class Inheritance
All Implemented Interfaces
org.springframework.web.servlet.resource.ResourceTransformer
Imports
java.io.IOException, jakarta.servlet.http.HttpServletRequest, org.apache.commons.logging.Log, .LogFactory, org.springframework.cache.Cache, .CacheManager, org.springframework.core.io.Resource, org.springframework.util.Assert

A org.springframework.web.servlet.resource.ResourceTransformer that checks a org.springframework.cache.Cache 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.
Author
Rossen Stoyanchev
Since
4.1

Field Summary

Modifier and TypeField and Description
private final Cache
private static final Log

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public Cache
getCache()

Return the configured Cache.

public Resource
transform(HttpServletRequest
the current request
request
,
Resource
the resource to transform
resource
,
ResourceTransformerChain
the chain of remaining transformers to delegate to
transformerChain
)

Implements org.springframework.web.servlet.resource.ResourceTransformer.transform.

Transform the given resource.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private final Cache cache
loggerback to summary
private static final Log logger

Constructor Detail

CachingResourceTransformerback to summary
public CachingResourceTransformer(Cache cache)
CachingResourceTransformerback to summary
public CachingResourceTransformer(CacheManager cacheManager, String cacheName)

Method Detail

getCacheback to summary
public Cache getCache()

Return the configured Cache.

transformback to summary
public Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) throws IOException

Implements org.springframework.web.servlet.resource.ResourceTransformer.transform.

Doc from org.springframework.web.servlet.resource.ResourceTransformer.transform.

Transform the given resource.

Parameters
request:HttpServletRequest

the current request

resource:Resource

the resource to transform

transformerChain:ResourceTransformerChain

the chain of remaining transformers to delegate to

Returns:Resource

the transformed resource (never null)

Annotations
@Override
Exceptions
IOException:
if the transformation fails