org.springframework.web.servlet.resource

Class CachingResourceTransformer

  • java.lang.Object
    • org.springframework.web.servlet.resource.CachingResourceTransformer
  • All Implemented Interfaces:
    ResourceTransformer


    public class CachingResourceTransformer
    extends java.lang.Object
    implements ResourceTransformer
    A ResourceTransformer that checks a 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.
    Since:
    4.1
    Author:
    Rossen Stoyanchev
    • Constructor Detail

      • CachingResourceTransformer

        public CachingResourceTransformer(Cache cache)
      • CachingResourceTransformer

        public CachingResourceTransformer(CacheManager cacheManager,
                                          java.lang.String cacheName)
    • Method Detail

      • getCache

        public Cache getCache()
        Return the configured Cache.
      • transform

        public Resource transform(HttpServletRequest request,
                                  Resource resource,
                                  ResourceTransformerChain transformerChain)
                           throws java.io.IOException
        Description copied from interface: ResourceTransformer
        Transform the given resource.
        Specified by:
        transform in interface ResourceTransformer
        Parameters:
        request - the current request
        resource - the resource to transform
        transformerChain - the chain of remaining transformers to delegate to
        Returns:
        the transformed resource (never null)
        Throws:
        java.io.IOException - if the transformation fails