Class AbstractResourceProcessor
java.lang.Object
org.broadleafcommerce.presentation.dialect.AbstractBroadleafTagReplacementProcessor
org.broadleafcommerce.common.web.processor.AbstractResourceProcessor
- All Implemented Interfaces:
org.broadleafcommerce.presentation.dialect.BroadleafProcessor,org.broadleafcommerce.presentation.dialect.BroadleafTagReplacementProcessor
- Direct Known Subclasses:
ResourceBundleProcessor,ResourcePreloadProcessor
public abstract class AbstractResourceProcessor
extends org.broadleafcommerce.presentation.dialect.AbstractBroadleafTagReplacementProcessor
An abstract tag replacement processor that provides methods to help get resource/bundle information
- Author:
- Jacob Mitash (jmitash)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ResourceBundlingServiceprotected org.springframework.core.env.Environmentprotected ResourcesRequestFields inherited from interface org.broadleafcommerce.presentation.dialect.BroadleafProcessor
DEFAULT_PRECEDENCE, DEFAULT_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildBundledFilesList(ResourceTagAttributes tagAttributes) Gets all the files that should be included in the bundleprotected abstract org.broadleafcommerce.presentation.model.BroadleafTemplateModelbuildModelBundled(List<String> attributeFiles, ResourceTagAttributes attributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) Builds the model that contains the bundled resources the tag should be replaced withprotected abstract org.broadleafcommerce.presentation.model.BroadleafTemplateModelbuildModelUnbundled(List<String> attributeFiles, ResourceTagAttributes attributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) Builds the model that contains the unbundled resources the tag should be replaced withprotected ResourceTagAttributesbuildResourceTagAttributes(Map<String, String> tagAttributes) Builds the tag attributes of the bundle tagprotected StringgetBundleAppendText(ResourceTagAttributes attributes) Gets the bundle append text, text that will be appended to the end of a bundleprotected StringGets the JavaScript that fires an event when a bundle is completedprotected booleanTells if bundling is enabledprotected StringgetBundlePath(ResourceTagAttributes attributes, List<String> files) Gets the bundle path.protected StringgetBundleUrl(String bundleName, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) Adds the context path to the bundleUrl.protected StringgetFullUnbundledFileName(String fileName, ResourceTagAttributes resourceTagAttributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) Gets the full path of an unbundled file.org.broadleafcommerce.presentation.model.BroadleafTemplateModelgetReplacementModel(String tagName, Map<String, String> tagAttributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) getRequestedFileNames(String rawFileNames) Gets a list of the requested files for bundlingpostProcessUnbundledFileList(List<String> attributeFiles, ResourceTagAttributes tagAttributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) Performs post processing on an unbundled file list to either grab the file list stored on the request (seeResourcesRequest) or use the files from the tag attributes and save them so they can be used again later without the files attribute.protected voidvalidateTagAttributes(ResourceTagAttributes resourceTagAttributes) Validates the requested tag attributesMethods inherited from class org.broadleafcommerce.presentation.dialect.AbstractBroadleafTagReplacementProcessor
getPrecedence, getPrefix, replacementNeedsProcessingMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.broadleafcommerce.presentation.dialect.BroadleafProcessor
getName
-
Field Details
-
environment
protected org.springframework.core.env.Environment environment -
bundlingService
-
resourcesRequest
-
-
Constructor Details
-
AbstractResourceProcessor
public AbstractResourceProcessor()
-
-
Method Details
-
getBundleEnabled
protected boolean getBundleEnabled()Tells if bundling is enabled- Returns:
- true if enabled, false otherwise
-
getReplacementModel
-
buildModelUnbundled
protected abstract org.broadleafcommerce.presentation.model.BroadleafTemplateModel buildModelUnbundled(List<String> attributeFiles, ResourceTagAttributes attributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) Builds the model that contains the unbundled resources the tag should be replaced with- Parameters:
attributeFiles- list of files that are to be includedattributes- the attributes of the original tag this processor replacescontext- the context of the original tag- Returns:
- model containing resources the tag should be replaced with
-
buildModelBundled
protected abstract org.broadleafcommerce.presentation.model.BroadleafTemplateModel buildModelBundled(List<String> attributeFiles, ResourceTagAttributes attributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) Builds the model that contains the bundled resources the tag should be replaced with- Parameters:
attributeFiles- list of files that are to be bundledattributes- the attributes of the original tag this processor replacescontext- the context of the original tag- Returns:
- model containing resources the tag should be replaced with
-
getRequestedFileNames
Gets a list of the requested files for bundling- Parameters:
rawFileNames- comma separated list of files- Returns:
- list of requested files with space trimmed or null if rawFileNames is null
-
buildResourceTagAttributes
Builds the tag attributes of the bundle tag- Parameters:
tagAttributes- the original attributes of the bundle tag- Returns:
- a
ResourceTagAttributescontaining the original bundle tag attributes
-
getFullUnbundledFileName
protected String getFullUnbundledFileName(String fileName, ResourceTagAttributes resourceTagAttributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) Gets the full path of an unbundled file.- Parameters:
fileName- the file name to parseresourceTagAttributes- the tag attributes of the original bundle tag (fileNamewill be used instead ofsrc)context- the template context- Returns:
- the full path of the unbundled file
-
getBundleUrl
protected String getBundleUrl(String bundleName, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) Adds the context path to the bundleUrl. We don't use the Thymeleaf "@" syntax or any other mechanism to encode this URL as the resolvers could have a conflict.For example, resolving a bundle named "style.css" that has a file also named "style.css" creates problems as the TF or version resolvers both want to version this file.
- Parameters:
bundleName- the path of the bundle to addcontext- the context of the original bundle tag- Returns:
- the full bundle URL
-
buildBundledFilesList
Gets all the files that should be included in the bundle- Parameters:
tagAttributes- the tag attributes of the resource tag to replace- Returns:
- list of all the files to include in the bundle
-
getBundlePath
Gets the bundle path. The path should still be put throughgetBundleUrl(String, BroadleafTemplateContext)to get the href/src appropriate for the HTML.- Parameters:
attributes- the attributes on the original resource tagfiles- the files requested with the bundle or null if not included- Returns:
- the bundle path
-
postProcessUnbundledFileList
protected List<String> postProcessUnbundledFileList(List<String> attributeFiles, ResourceTagAttributes tagAttributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context) Performs post processing on an unbundled file list to either grab the file list stored on the request (seeResourcesRequest) or use the files from the tag attributes and save them so they can be used again later without the files attribute.- Parameters:
attributeFiles- the files that were on the attribute (and any additional files to include)tagAttributes- the attributes that were on the original resource tagcontext- the context of the original resource tag- Returns:
- list of files to use as resources
-
getBundleAppendText
Gets the bundle append text, text that will be appended to the end of a bundle- Parameters:
attributes- the original resource tag attributes- Returns:
- bundle append text
-
getBundleCompleteEventJavaScript
Gets the JavaScript that fires an event when a bundle is completed- Parameters:
attributes- the attributes to build the event off of- Returns:
- JavaScript that fires an event or null if none requested
-
validateTagAttributes
Validates the requested tag attributes- Parameters:
resourceTagAttributes- the tag attributes from the original resource tag
-