public class HtmlStaplerBundlesManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
HtmlStaplerBundlesManager.Strategy |
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,java.lang.String> |
actionBundles |
protected int |
bundleCount |
protected java.lang.String |
bundleFolder |
protected java.lang.String |
contextPath |
protected boolean |
downloadLocal |
protected java.lang.String |
localAddressAndPort |
protected java.lang.String |
localFilesEncoding |
protected java.util.Map<java.lang.String,java.lang.String> |
mirrors |
protected boolean |
notFoundExceptionEnabled |
protected int |
randomDigestChars |
protected boolean |
sortResources |
protected java.lang.String |
staplerPath |
protected HtmlStaplerBundlesManager.Strategy |
strategy |
protected java.lang.String |
webRoot |
Constructor and Description |
---|
HtmlStaplerBundlesManager(java.lang.String contextPath,
java.lang.String webRoot,
HtmlStaplerBundlesManager.Strategy strategy)
Creates new instance and initialize it.
|
Modifier and Type | Method and Description |
---|---|
protected void |
createBundle(java.lang.String contextPath,
java.lang.String actionPath,
java.lang.String bundleId,
java.util.List<java.lang.String> sources)
Creates bundle file by loading resource files content.
|
protected java.io.File |
createBundleFile(java.lang.String bundleId)
Creates bundle file in bundleFolder/staplerPath.
|
protected java.lang.String |
createDigest(java.lang.String source)
Creates digest i.e. bundle id from given string.
|
protected java.lang.String |
fixCssRelativeUrls(java.lang.String content,
java.lang.String src)
Returns the content with all relative URLs fixed.
|
protected java.lang.String |
fixRelativeUrl(java.lang.String url,
java.lang.String offsetPath)
For a given URL (optionally quoted), produces CSS URL
where relative paths are fixed and prefixed with offsetPath.
|
java.lang.String |
getBundleFolder()
Returns bundles folder.
|
java.lang.String |
getLocalAddressAndPort()
Returns local address and port for downloading
local resources.
|
java.lang.String |
getLocalFilesEncoding()
Returns local files encoding.
|
int |
getRandomDigestChars()
Returns the number of random digest chars.
|
java.lang.String |
getStaplerPath()
Returns stapler path.
|
HtmlStaplerBundlesManager.Strategy |
getStrategy()
Returns current
strategy . |
java.lang.String |
getWebRoot()
Returns current web root.
|
protected boolean |
isCssResource(java.lang.String src)
Returns
true if resource is CSS, so the
CSS urls can be fixed. |
boolean |
isDownloadLocal()
Returns
true if local resource files are downloaded
and not loaded from file system. |
protected boolean |
isExternalResource(java.lang.String link)
Returns
true if resource link has to be downloaded. |
boolean |
isNotFoundExceptionEnabled()
Returns
true if exception will be thrown when
resource is not found. |
boolean |
isSortResources()
Returns
true if resources are sorted before
bundle id (a digest) is created. |
java.io.File |
lookupBundleFile(java.lang.String bundleId)
Lookups for bundle file.
|
java.lang.String |
lookupBundleId(java.lang.String actionPath)
Lookups for a bundle id for a given action.
|
java.io.File |
lookupGzipBundleFile(java.io.File file)
Locates gzipped version of bundle file.
|
protected java.lang.String |
onResourceContent(java.lang.String content)
Invoked before resource content is stored in the bundle.
|
java.lang.String |
registerBundle(java.lang.String contextPath,
java.lang.String actionPath,
java.lang.String tempBundleId,
java.lang.String bundleContentType,
java.util.List<java.lang.String> sources)
Registers new bundle that consist of provided list of source paths.
|
java.lang.String |
registerNewBundleId()
Registers new, temporary bundle id for given action path.
|
void |
reset()
Clears all settings and removes all created bundle files from file system.
|
protected java.lang.String |
resolveRealActionPath(java.lang.String actionPath)
Resolves real action path for given one.
|
void |
setBundleFolder(java.lang.String bundleFolder)
Sets bundle folder.
|
void |
setDownloadLocal(boolean downloadLocal)
Sets if local resource files should be downloaded or loaded from file system.
|
void |
setLocalAddressAndPort(java.lang.String localAddressAndPort)
Specifies local address and port for downloading
local resources.
|
void |
setLocalFilesEncoding(java.lang.String localFilesEncoding)
Sets local files encoding.
|
void |
setNotFoundExceptionEnabled(boolean notFoundExceptionEnabled)
Sets if exception should be thrown when some resource is not found.
|
void |
setRandomDigestChars(int randomDigestChars)
Sets the number of random characters that will be appended to the
digest . |
void |
setSortResources(boolean sortResources)
Sets the resources sorting before bundle id (i.e. a digest)
is created.
|
void |
setStaplerPath(java.lang.String staplerPath)
Sets stapler path.
|
BundleAction |
start(java.lang.String servletPath,
java.lang.String bundleName)
Starts bundle usage by creating new
BundleAction . |
protected int bundleCount
protected java.util.Map<java.lang.String,java.lang.String> actionBundles
protected java.util.Map<java.lang.String,java.lang.String> mirrors
protected final java.lang.String webRoot
protected final java.lang.String contextPath
protected final HtmlStaplerBundlesManager.Strategy strategy
protected java.lang.String localFilesEncoding
protected java.lang.String bundleFolder
protected java.lang.String staplerPath
protected java.lang.String localAddressAndPort
protected boolean downloadLocal
protected boolean sortResources
protected boolean notFoundExceptionEnabled
protected int randomDigestChars
public HtmlStaplerBundlesManager(java.lang.String contextPath, java.lang.String webRoot, HtmlStaplerBundlesManager.Strategy strategy)
public BundleAction start(java.lang.String servletPath, java.lang.String bundleName)
BundleAction
.public HtmlStaplerBundlesManager.Strategy getStrategy()
strategy
.public boolean isSortResources()
true
if resources are sorted before
bundle id (a digest) is created. When sorting is enabled,
two pages will share the same bundle even if they list
resources in different order.public void setSortResources(boolean sortResources)
public java.lang.String getWebRoot()
public java.lang.String getBundleFolder()
public void setBundleFolder(java.lang.String bundleFolder)
public java.lang.String getStaplerPath()
public void setStaplerPath(java.lang.String staplerPath)
public java.lang.String getLocalFilesEncoding()
public void setLocalFilesEncoding(java.lang.String localFilesEncoding)
public java.lang.String getLocalAddressAndPort()
public void setLocalAddressAndPort(java.lang.String localAddressAndPort)
public boolean isDownloadLocal()
true
if local resource files are downloaded
and not loaded from file system.public void setDownloadLocal(boolean downloadLocal)
public boolean isNotFoundExceptionEnabled()
true
if exception will be thrown when
resource is not found.public void setNotFoundExceptionEnabled(boolean notFoundExceptionEnabled)
public int getRandomDigestChars()
public void setRandomDigestChars(int randomDigestChars)
digest
. When it is set to 0, nothing
will be appended to the digest. Otherwise, a random string will be
generated (containing only letters and digits) and appended to the
digest.
Random digest chars is a unique key per one VM! This key is initialized only once. This is useful to automatically expire any cache that browsers may have in JS and CSS files, so that changes in those files will be downloaded by the browser.
protected java.io.File createBundleFile(java.lang.String bundleId)
public java.io.File lookupBundleFile(java.lang.String bundleId)
public java.io.File lookupGzipBundleFile(java.io.File file) throws java.io.IOException
java.io.IOException
public java.lang.String lookupBundleId(java.lang.String actionPath)
null
if action still has no bundle.
Returns an empty string if action has an empty bundle.public java.lang.String registerNewBundleId()
public java.lang.String registerBundle(java.lang.String contextPath, java.lang.String actionPath, java.lang.String tempBundleId, java.lang.String bundleContentType, java.util.List<java.lang.String> sources)
protected java.lang.String createDigest(java.lang.String source)
protected void createBundle(java.lang.String contextPath, java.lang.String actionPath, java.lang.String bundleId, java.util.List<java.lang.String> sources) throws java.io.IOException
java.io.IOException
protected boolean isExternalResource(java.lang.String link)
true
if resource link has to be downloaded.
By default, if resource link starts with "http://" or with "https://"
it will be considered as external resource.protected java.lang.String onResourceContent(java.lang.String content)
protected java.lang.String resolveRealActionPath(java.lang.String actionPath)
public void reset()
protected boolean isCssResource(java.lang.String src)
true
if resource is CSS, so the
CSS urls can be fixed.protected java.lang.String fixCssRelativeUrls(java.lang.String content, java.lang.String src)
protected java.lang.String fixRelativeUrl(java.lang.String url, java.lang.String offsetPath)
Copyright © 2003-present Jodd Team