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 Summary
FieldsModifier and TypeFieldDescriptionprotected javax.cache.CacheManager
static final int
protected ResourceRequestExtensionManager
protected javax.cache.Cache<String,
org.springframework.core.io.Resource> protected static final org.apache.commons.logging.Log
protected StatisticsService
protected StreamingTransactionCapableUtil
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
protected String
abstract org.springframework.core.io.Resource
getFileContents
(String path, List<org.springframework.core.io.Resource> locations) protected javax.cache.Cache<String,
org.springframework.core.io.Resource> int
getOrder()
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 locationorg.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)
-
Field Details
-
DEFAULT_ORDER
public static final int DEFAULT_ORDER- See Also:
-
LOG
protected static final org.apache.commons.logging.Log LOG -
statisticsService
-
transUtil
-
extensionManager
-
cacheManager
protected javax.cache.CacheManager cacheManager -
generatedResourceCache
-
-
Constructor Details
-
AbstractGeneratedResourceHandler
public AbstractGeneratedResourceHandler()
-
-
Method Details
-
canHandle
- 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
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
-