Class AbstractGeneratedResourceHandler

java.lang.Object
org.broadleafcommerce.common.web.resource.AbstractGeneratedResourceHandler
All Implemented Interfaces:
org.springframework.core.Ordered
Direct Known Subclasses:
RuleBuilderEnumOptionsResourceHandler

public abstract class AbstractGeneratedResourceHandler extends Object implements org.springframework.core.Ordered
An abstract GeneratedResourceHandler that is capable of responding to a single specified filename and generate contents for that filename. This abstract parent will handle caching of the generated resource.
Author:
Andre Azzolini (apazzolini)
  • Field Details

    • DEFAULT_ORDER

      public static final int DEFAULT_ORDER
      See Also:
    • LOG

      protected static final org.apache.commons.logging.Log LOG
    • statisticsService

      protected StatisticsService statisticsService
    • transUtil

      protected StreamingTransactionCapableUtil transUtil
    • extensionManager

      protected ResourceRequestExtensionManager extensionManager
    • cacheManager

      protected javax.cache.CacheManager cacheManager
    • generatedResourceCache

      protected javax.cache.Cache<String,org.springframework.core.io.Resource> generatedResourceCache
  • Constructor Details

    • AbstractGeneratedResourceHandler

      public AbstractGeneratedResourceHandler()
  • Method Details

    • canHandle

      public abstract boolean canHandle(String path)
      Parameters:
      path -
      Returns:
      booelean determining whether or not this handler is able to handle the given request
    • getFileContents

      public abstract org.springframework.core.io.Resource getFileContents(String path, List<org.springframework.core.io.Resource> locations)
      Parameters:
      path -
      locations -
      Returns:
      the Resource representing this file
    • isCachedResourceExpired

      public abstract boolean isCachedResourceExpired(GeneratedResource cachedResource, String path, List<org.springframework.core.io.Resource> locations)
      Parameters:
      cachedResource -
      path -
      locations -
      Returns:
      whether or not the given cachedResource needs to be regenerated
    • getResource

      public org.springframework.core.io.Resource getResource(String path, List<org.springframework.core.io.Resource> locations)
      Attempts to retrive the requested resource from cache. If not cached, generates the resource, caches it, and then returns it
      Parameters:
      path -
      locations -
      Returns:
      the generated resource
    • getRawResource

      protected org.springframework.core.io.Resource getRawResource(String path, List<org.springframework.core.io.Resource> locations)
      This method can be used to read in a resource given a path and at least one resource location
      Parameters:
      path -
      locations -
      Returns:
      the resource from the file system, classpath, etc, if it exists
    • getResourceContents

      protected String getResourceContents(org.springframework.core.io.Resource resource) throws IOException
      Parameters:
      resource -
      Returns:
      the UTF-8 String represetation of the contents of the resource
      Throws:
      IOException
    • getGeneratedResourceCache

      protected javax.cache.Cache<String,org.springframework.core.io.Resource> getGeneratedResourceCache()
    • getCacheName

      protected String getCacheName()
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered