Class MinifiedScriptCache
java.lang.Object
org.gatein.portal.controller.resource.MinifiedScriptCache
Minified scripts kept on disk, so that a restart or a reload minifies only
the scripts whose source changed, and again those the compiler rejected. A
file's name is the SHA-256 of the script's source, of Closure's release
version and of the compiler options, so its content is the minification of
that source, whichever thread or node wrote it. A build that reads a file
makes it recent:
deleteUnused(), once the startup build is done,
deletes the files no build read for RETENTION.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
CACHE_DIR_PROPERTY
Where minified scripts are kept across restarts. Its files are served as the platform's scripts: only the server's account may write in it.- See Also:
-
RETENTION
Files no build read for that long are deleted after the startup build.
-
-
Constructor Details
-
MinifiedScriptCache
- Parameters:
configuredDirectory- the directory to use; when blank, or when it cannot be created or written, a temporary directory deleted when the JVM exitscompilerOptions- the compiler options, as part of each file's key
-
-
Method Details
-
configuredDirectory
- Returns:
- the directory
CACHE_DIR_PROPERTYnames; when it is not set,${gatein.data.dir}/js-cache; an empty value, or no data directory, leaves it empty
-
get
- Parameters:
source- a script's sourceminifier- minifies a source, or returns null when it cannot- Returns:
- the minified script, read from the directory when a previous minification of the same source left it there, else the minifier's result, written to the directory when not null. An empty file for a non-blank source is a miss: a write a host crash cut short leaves one
-
getDirectory
-
isTemporary
public boolean isTemporary() -
deleteUnused
public void deleteUnused()Deletes the cache's files that no build read forRETENTION. Run once the startup build has read the scripts it serves: their files are then recent, however long ago the previous build ran.
-