org.broadleafcommerce.common.resource.service
Class ResourceBundlingServiceImpl

java.lang.Object
  extended by org.broadleafcommerce.common.resource.service.ResourceBundlingServiceImpl
All Implemented Interfaces:
ResourceBundlingService

@Service(value="blResourceBundlingService")
public class ResourceBundlingServiceImpl
extends Object
implements ResourceBundlingService

Author:
Andre Azzolini (apazzolini)
See Also:
ResourceBundlingService

Field Summary
protected  Map<String,List<String>> additionalBundleFiles
           
protected  String assetFileSystemPath
           
protected  Map<String,Collection<org.springframework.core.io.Resource>> bundles
           
protected  net.sf.ehcache.Cache bundleVersionsCache
           
protected static String DEFAULT_STORAGE_DIRECTORY
           
protected static org.apache.commons.logging.Log LOG
           
protected  ResourceMinificationService minifyService
           
 
Constructor Summary
ResourceBundlingServiceImpl()
           
 
Method Summary
protected  org.springframework.core.io.Resource createBundle(String versionedBundleName)
           
 Map<String,List<String>> getAdditionalBundleFiles()
           
 List<String> getAdditionalBundleFiles(String bundleName)
           
 org.springframework.core.io.Resource getBundle(String versionedBundleName)
          For the given versioned bundle name, returns a Resource that holds the contents of the combined, and possibly minified (if enabled) bundle.
protected  String getBundleName(String bundleName, String version)
           
protected  String getBundleVersion(LinkedHashMap<String,org.springframework.core.io.Resource> foundResources)
           
protected  net.sf.ehcache.Cache getBundleVersionsCache()
           
protected  String getFilePath(String name)
           
 String getVersionedBundleName(String unversionedBundleName)
          For a given unversioned bundle name, such as "global.js", returns the currently known versioned bundle name, such as "global12345.js".
 boolean hasBundle(String versionedBundle)
           
protected  org.springframework.core.io.Resource readBundle(String versionedBundleName)
           
 String registerBundle(String bundleName, List<String> files, BroadleafResourceHttpRequestHandler handler)
          Registers a new bundle with the given name to its files.
protected  void saveBundle(org.springframework.core.io.Resource resource)
           
 void setAdditionalBundleFiles(Map<String,List<String>> additionalBundleFiles)
           
 
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

DEFAULT_STORAGE_DIRECTORY

protected static final String DEFAULT_STORAGE_DIRECTORY

bundles

protected Map<String,Collection<org.springframework.core.io.Resource>> bundles

bundleVersionsCache

protected net.sf.ehcache.Cache bundleVersionsCache

additionalBundleFiles

protected Map<String,List<String>> additionalBundleFiles

assetFileSystemPath

@Value(value="${asset.server.file.system.path}")
protected String assetFileSystemPath

minifyService

protected ResourceMinificationService minifyService
Constructor Detail

ResourceBundlingServiceImpl

public ResourceBundlingServiceImpl()
Method Detail

getBundle

public org.springframework.core.io.Resource getBundle(String versionedBundleName)
Description copied from interface: ResourceBundlingService
For the given versioned bundle name, returns a Resource that holds the contents of the combined, and possibly minified (if enabled) bundle.

Specified by:
getBundle in interface ResourceBundlingService
Returns:
the Resource

readBundle

protected org.springframework.core.io.Resource readBundle(String versionedBundleName)

getFilePath

protected String getFilePath(String name)

createBundle

protected org.springframework.core.io.Resource createBundle(String versionedBundleName)

saveBundle

protected void saveBundle(org.springframework.core.io.Resource resource)

getVersionedBundleName

public String getVersionedBundleName(String unversionedBundleName)
Description copied from interface: ResourceBundlingService
For a given unversioned bundle name, such as "global.js", returns the currently known versioned bundle name, such as "global12345.js".

Specified by:
getVersionedBundleName in interface ResourceBundlingService
Returns:
the versioned bundle name

hasBundle

public boolean hasBundle(String versionedBundle)
Specified by:
hasBundle in interface ResourceBundlingService
Returns:
whether or not the given versioned bundle name is currently registered in the system

registerBundle

public String registerBundle(String bundleName,
                             List<String> files,
                             BroadleafResourceHttpRequestHandler handler)
                      throws IOException
Description copied from interface: ResourceBundlingService
Registers a new bundle with the given name to its files. Will utilize the locations map in handler as well as any configured generated resource handlers in the handler to determine legitimate paths for each of the files in the list.

Specified by:
registerBundle in interface ResourceBundlingService
Returns:
the versioned bundle name
Throws:
IOException

getBundleName

protected String getBundleName(String bundleName,
                               String version)

getBundleVersion

protected String getBundleVersion(LinkedHashMap<String,org.springframework.core.io.Resource> foundResources)
                           throws IOException
Throws:
IOException

getAdditionalBundleFiles

public List<String> getAdditionalBundleFiles(String bundleName)
Specified by:
getAdditionalBundleFiles in interface ResourceBundlingService
Returns:
a list of additional files that are registered for the given bundle name

getAdditionalBundleFiles

public Map<String,List<String>> getAdditionalBundleFiles()

setAdditionalBundleFiles

public void setAdditionalBundleFiles(Map<String,List<String>> additionalBundleFiles)

getBundleVersionsCache

protected net.sf.ehcache.Cache getBundleVersionsCache()


Copyright © 2013. All Rights Reserved.