org.broadleafcommerce.common.web.resource
Class AbstractGeneratedResourceHandler

java.lang.Object
  extended by org.broadleafcommerce.common.web.resource.AbstractGeneratedResourceHandler
Direct Known Subclasses:
BLCJSResourceHandler

public abstract class AbstractGeneratedResourceHandler
extends Object

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 Summary
protected  net.sf.ehcache.Cache generatedResourceCache
           
protected static org.apache.commons.logging.Log LOG
           
protected  StatisticsService statisticsService
           
 
Constructor Summary
AbstractGeneratedResourceHandler()
           
 
Method Summary
abstract  boolean canHandle(String path)
           
abstract  org.springframework.core.io.Resource getFileContents(String path, List<org.springframework.core.io.Resource> locations)
           
protected  net.sf.ehcache.Cache getGeneratedResourceCache()
           
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
 org.springframework.core.io.Resource getResource(String path, List<org.springframework.core.io.Resource> locations)
          Attempts to retrive the requested resource from cache.
protected  String getResourceContents(org.springframework.core.io.Resource resource)
           
abstract  boolean isCachedResourceExpired(GeneratedResource cachedResource, String path, List<org.springframework.core.io.Resource> locations)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

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

statisticsService

protected StatisticsService statisticsService

generatedResourceCache

protected net.sf.ehcache.Cache generatedResourceCache
Constructor Detail

AbstractGeneratedResourceHandler

public AbstractGeneratedResourceHandler()
Method Detail

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:
request -
location -
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 net.sf.ehcache.Cache getGeneratedResourceCache()


Copyright © 2013. All Rights Reserved.