@Service(value="blResourceBundlingService") public class ResourceBundlingServiceImpl extends Object implements ResourceBundlingService
ResourceBundlingService
Modifier and Type | Field and Description |
---|---|
protected Map<String,List<String>> |
additionalBundleFiles
This has to use an @Resource annotation because Spring's @Autowired cannot work with the type erasure from the
Map
|
protected org.springframework.context.ApplicationContext |
appctx |
protected org.springframework.web.servlet.resource.ResourceHttpRequestHandler |
cssResourceHandler |
protected org.springframework.core.env.Environment |
environment |
protected BroadleafFileService |
fileService |
protected org.springframework.web.servlet.resource.ResourceHttpRequestHandler |
jsResourceHandler
These properties are looked up manually within
initializeResources(ContextRefreshedEvent) |
protected static org.apache.commons.logging.Log |
LOG |
protected StatisticsService |
statisticsService |
Constructor and Description |
---|
ResourceBundlingServiceImpl() |
Modifier and Type | Method and Description |
---|---|
protected String |
addVersion(String requestPath,
String version)
Copied from Spring 4.1 AbstractVersionStrategy
|
boolean |
checkForRegisteredBundleFile(String versionedBundleName)
Tells if the given versioned bundle exists
|
protected org.springframework.core.io.Resource |
createBundle(String versionedBundleName,
List<String> filePaths,
org.springframework.web.servlet.resource.ResourceResolverChain resolverChain,
List<org.springframework.core.io.Resource> locations) |
protected org.springframework.core.io.Resource |
createBundle(String versionedBundleName,
List<String> filePaths,
org.springframework.web.servlet.resource.ResourceResolverChain resolverChain,
List<org.springframework.core.io.Resource> locations,
String bundleAppend) |
protected void |
createBundleIfNeeded(String versionedBundleName,
List<String> filePaths,
org.springframework.web.servlet.resource.ResourceResolverChain resolverChain,
List<org.springframework.core.io.Resource> locations) |
protected void |
createBundleIfNeeded(String versionedBundleName,
List<String> filePaths,
org.springframework.web.servlet.resource.ResourceResolverChain resolverChain,
List<org.springframework.core.io.Resource> locations,
String bundleAppend) |
List<String> |
findBundlesNameByResourceFileName(String fileName)
Returns names of bundles which contain the given file
|
protected org.springframework.web.servlet.resource.ResourceHttpRequestHandler |
findResourceHttpRequestHandler(String resourceName) |
List<String> |
getAdditionalBundleFiles(String bundleName)
Through configuration, you can provide additional files that will be automatically included for any bundle.
|
protected Charset |
getBundleCharSet() |
protected org.springframework.core.io.Resource |
getBundledResource(String versionedBundleName) |
protected String |
getBundleName(String bundleName,
String version) |
protected String |
getBundleVersion(LinkedHashMap<String,org.springframework.core.io.Resource> foundResources) |
protected String |
getCacheKey(String unversionedBundleName,
List<String> files) |
protected String |
getResourcePath(String name)
Returns the resource path for the given name in URL-format (meaning, / separators)
|
void |
initializeResources(org.springframework.context.event.ContextRefreshedEvent event)
Initalize the blJsResources and blCssResources.
|
protected boolean |
isCSSResource(String resourceName) |
protected boolean |
isJavaScriptResource(String resourceName) |
protected String |
lookupBundlePath(String requestPath) |
protected org.springframework.core.io.Resource |
readBundle(String versionedBundleName) |
org.springframework.core.io.Resource |
rebuildBundledResource(String requestedBundleName)
Returns a newly rebuilt bundled resource given that the passed requestedBundleName had previously been built and cached/persisted via
the
ResourceBundlingService.resolveBundleResourceName(String, String, List) method. |
boolean |
removeBundle(String bundleName) |
org.springframework.core.io.Resource |
resolveBundleResource(String versionedBundleResourceName)
Returns a Resource for passed in versionedBundleResourceName.
|
String |
resolveBundleResourceName(String requestedBundleName,
String mappingPrefix,
List<String> files)
Returns a file name representing a versioned copy of the bundle.
|
String |
resolveBundleResourceName(String requestedBundleName,
String mappingPrefix,
List<String> files,
String bundleAppend)
Returns a file name representing a versioned copy of the bundle with the
bundleAppend text appended
to the end of the bundle. |
protected void |
saveBundle(org.springframework.core.io.Resource resource) |
void |
setAdditionalBundleFiles(Map<String,List<String>> additionalBundleFiles) |
protected static final org.apache.commons.logging.Log LOG
protected Map<String,List<String>> additionalBundleFiles
protected BroadleafFileService fileService
protected org.springframework.web.servlet.resource.ResourceHttpRequestHandler jsResourceHandler
initializeResources(ContextRefreshedEvent)
protected org.springframework.web.servlet.resource.ResourceHttpRequestHandler cssResourceHandler
@Autowired protected org.springframework.context.ApplicationContext appctx
protected StatisticsService statisticsService
@Autowired protected org.springframework.core.env.Environment environment
@EventListener public void initializeResources(org.springframework.context.event.ContextRefreshedEvent event)
public org.springframework.core.io.Resource rebuildBundledResource(String requestedBundleName)
ResourceBundlingService
ResourceBundlingService.resolveBundleResourceName(String, String, List)
method.rebuildBundledResource
in interface ResourceBundlingService
requestedBundleName
- the requested bundle namepublic String resolveBundleResourceName(String requestedBundleName, String mappingPrefix, List<String> files)
ResourceBundlingService
First computes the bundle version by examining the files in the bundle. If the bundle does not exist, this method will create it.
resolveBundleResourceName
in interface ResourceBundlingService
requestedBundleName
- the requested bundle namemappingPrefix
- the path prefix for the bundlefiles
- the files the bundle should containpublic String resolveBundleResourceName(String requestedBundleName, String mappingPrefix, List<String> files, String bundleAppend)
ResourceBundlingService
bundleAppend
text appended
to the end of the bundle.
First computes the bundle version by examining the files in the bundle. If the bundle does not exist, this method will create it.
resolveBundleResourceName
in interface ResourceBundlingService
requestedBundleName
- the requested bundle namemappingPrefix
- the path prefix for the bundlefiles
- the files the bundle should containbundleAppend
- the text to append at the end of the bundlepublic org.springframework.core.io.Resource resolveBundleResource(String versionedBundleResourceName)
ResourceBundlingService
If the bundle does not exist, this method will attempt to create it by using the list
of files that were registered with the initial call to
ResourceBundlingService.resolveBundleResourceName(String, String, List)
resolveBundleResource
in interface ResourceBundlingService
versionedBundleResourceName
- the versioned bundle resource namepublic boolean checkForRegisteredBundleFile(String versionedBundleName)
ResourceBundlingService
checkForRegisteredBundleFile
in interface ResourceBundlingService
versionedBundleName
- the versioned bundle nameprotected org.springframework.core.io.Resource getBundledResource(String versionedBundleName)
protected void createBundleIfNeeded(String versionedBundleName, List<String> filePaths, org.springframework.web.servlet.resource.ResourceResolverChain resolverChain, List<org.springframework.core.io.Resource> locations)
protected void createBundleIfNeeded(String versionedBundleName, List<String> filePaths, org.springframework.web.servlet.resource.ResourceResolverChain resolverChain, List<org.springframework.core.io.Resource> locations, String bundleAppend)
protected org.springframework.core.io.Resource createBundle(String versionedBundleName, List<String> filePaths, org.springframework.web.servlet.resource.ResourceResolverChain resolverChain, List<org.springframework.core.io.Resource> locations)
protected org.springframework.core.io.Resource createBundle(String versionedBundleName, List<String> filePaths, org.springframework.web.servlet.resource.ResourceResolverChain resolverChain, List<org.springframework.core.io.Resource> locations, String bundleAppend)
protected void saveBundle(org.springframework.core.io.Resource resource)
protected String getBundleVersion(LinkedHashMap<String,org.springframework.core.io.Resource> foundResources) throws IOException
IOException
public List<String> getAdditionalBundleFiles(String bundleName)
ResourceBundlingService
getAdditionalBundleFiles
in interface ResourceBundlingService
bundleName
- the name of the bundle to get additional files forpublic void setAdditionalBundleFiles(Map<String,List<String>> additionalBundleFiles)
protected String addVersion(String requestPath, String version)
requestPath
- version
- protected org.springframework.core.io.Resource readBundle(String versionedBundleName)
protected org.springframework.web.servlet.resource.ResourceHttpRequestHandler findResourceHttpRequestHandler(String resourceName)
protected boolean isJavaScriptResource(String resourceName)
protected boolean isCSSResource(String resourceName)
protected String getResourcePath(String name)
name
- protected Charset getBundleCharSet()
public List<String> findBundlesNameByResourceFileName(String fileName)
ResourceBundlingService
findBundlesNameByResourceFileName
in interface ResourceBundlingService
fileName
- file to find in the bunglepublic boolean removeBundle(String bundleName)
removeBundle
in interface ResourceBundlingService
Copyright © 2022. All rights reserved.