| java.lang.Object org.openlaszlo.cache.Cache org.openlaszlo.cm.CompilationManager
CompilationManager | public class CompilationManager extends Cache (Code) | | A CompilationManager is responsible for maintaining
the correspondence between source and object files. It's
responsible for dependency analysis, caching, and selective recompilation.
The main entry point to the Compilationmanager code is getObjectStream
A CompilationManager is constructed with a source directory, where it
looks for source files, and a cache directory, where it places
compiled object files and cached (dependency) information. It can be
instructed to always recompile files, never recompile them so long
as they exist, or use dependency information that it creates during
the course of a file compilation to determine whether a file is out
of date. See the documentation for getProperty() for a description
of how to select between these behaviors.
The compilation manager currently uses itself to represent the
cache, and methods that access the cache are synchronized. This
would have to change to support multiple readers.
Methods that trigger recompilation are synchronized: it's safe for
multiple threads to contain references to a compilation manager if
they are only using it to compile. Accessor methods should only be
called single-threaded. Two compilation managers shouldn't be
pointed at the same cache directory.
|
Method Summary | |
protected void | afterCacheRead(Object metaData) | public boolean | clearCacheDirectory() Clear the cache. | public synchronized void | compileItem(Item item, String pathname, Properties compilationProperties) Compiles the file named by pathname and leaves the result
in the cached item. | static Serializable | computeKey(String pathname, Properties props) | public synchronized void | convertItemEncoding(Item src, Item dest, String pathname, String enc, Properties props) | public File | getCacheSourcePath(String srcName, String webappPath) Given the pathname of a file, return a file name
for an "source" version of this file that lives in the cache. | public synchronized Canvas | getCanvas(String pathname) | public synchronized Canvas | getCanvas(String pathname, Properties props) | public CompilerMediaCache | getCompilerMediaCache() | public synchronized String | getInfoXML(String pathname, Properties props) | public synchronized Item | getItem(String pathname, Properties props) Get the cached item. | public synchronized long | getLastModified(String pathname, Properties props) | public synchronized File | getObjectFile(String pathname, Properties props) Returns a File containing the compiled form of the file
named by pathname, suitable play on the client. | public synchronized InputStream | getObjectStream(String pathname, Properties props) Returns an InputStream containing the compiled form of the file
named by pathname, suitable play on the client. | public Properties | getProperties() Miscellaneous properties. | public synchronized InputStream | getScriptStream(String pathname, Properties props) Returns an InputStream containing the script form of the file
named by pathname, suitable play on the client. | public boolean | isItemUpToDate(Item item, String pathname, Properties props) true if the item is up to date Parameters: pathname - a String value. | public void | setProperty(String key, String value) | public void | setSourceDirectory(File sourceDirectory) Sets the source directory. |
mCacheDirectory | protected File mCacheDirectory(Code) | | See the constructor.
|
mSourceDirectory | protected File mSourceDirectory(Code) | | See the constructor.
|
CompilationManager | public CompilationManager(File sourceDirectory, File cacheDirectory, Properties props) throws IOException(Code) | | Creates a new CompilationManager instance.
Parameters: sourceDirectory - a File naming a directory,that is used as a base for resolving relative names that arepassed to getObjectData. Parameters: cacheDirectory - a File naming a directory.The CompilationManager places object files anddependency-tracking information here, to avoid unnecessarysubsequent recompilation. |
afterCacheRead | protected void afterCacheRead(Object metaData)(Code) | | |
clearCacheDirectory | public boolean clearCacheDirectory()(Code) | | Clear the cache.
true if full removal of cache was successful, otherwise false. |
compileItem | public synchronized void compileItem(Item item, String pathname, Properties compilationProperties) throws CompilationError(Code) | | Compiles the file named by pathname and leaves the result
in the cached item. If the file can't be compiled and
debugCompilationErrors is true, returns an HTML document
describing the error; otherwise, passes the exception.
Parameters: pathname - a String value. Ifpathname is relative, it is resolved relative to theCompilationManager's sourceDirectory. Parameters: props - properties that affect the compile. the bytes of the object file exception: CompilationError - if an error occursThe PROPS parameter may contain - "Content-Encoding" => the encoding of the output (ignore if null)
|
convertItemEncoding | public synchronized void convertItemEncoding(Item src, Item dest, String pathname, String enc, Properties props)(Code) | | Take source item, un-encode it, and then re-encode and store in dest item
with the specified encoding
Parameters: src - - source item Parameters: dest - - dest item Parameters: pathname - - pathname for destination item Parameters: enc - - encoding for dest Parameters: props - - properties for compileFor now, hardcoded to only support gzip. |
getCacheSourcePath | public File getCacheSourcePath(String srcName, String webappPath)(Code) | | Given the pathname of a file, return a file name
for an "source" version of this file that lives in the cache.
Parameters: srcName - path to file in source directory Parameters: webappPath - real path for web application a File |
getCanvas | public synchronized Canvas getCanvas(String pathname, Properties props) throws CompilationError, IOException(Code) | | Return the canvas associated with the given LZX file
the canvas Parameters: pathname - path to the LZX file Parameters: props - props for dependency tracker and compiler throws: CompilationError - if there is a compilation errorin the file |
getCompilerMediaCache | public CompilerMediaCache getCompilerMediaCache()(Code) | | Returns the media cache for the compilation manager
|
getItem | public synchronized Item getItem(String pathname, Properties props) throws IOException(Code) | | Get the cached item. Recompile or convert encoding as needed.
Parameters: pathname - path to the LZX file Parameters: props - params for compiler |
getLastModified | public synchronized long getLastModified(String pathname, Properties props) throws CompilationError, IOException(Code) | | Return the last modified time associated with the given LZX file
the last modified time in utc Parameters: pathname - path to the LZX file Parameters: props - params for dependency tracker and compiler throws: CompilationError - if there is a compilation errorin the file |
getObjectFile | public synchronized File getObjectFile(String pathname, Properties props) throws CompilationError, IOException(Code) | | Returns a File containing the compiled form of the file
named by pathname, suitable play on the client.
Parameters: pathname - a String value. Ifpathname is relative, it is resolved relative to theCompilationManager's sourceDirectory. Parameters: props - params for dependency tracker and compiler the compiled File object. exception: CompilationError - if an error occurs. |
getObjectStream | public synchronized InputStream getObjectStream(String pathname, Properties props) throws CompilationError, IOException(Code) | | Returns an InputStream containing the compiled form of the file
named by pathname, suitable play on the client.
Parameters: pathname - a String value. Ifpathname is relative, it is resolved relative to theCompilationManager's sourceDirectory. Parameters: props - params for dependency tracker and compiler the compiled File object. exception: CompilationError - if an error occurs. |
getProperties | public Properties getProperties()(Code) | | Miscellaneous properties.
- recompile=always
- Always recompile object files, regardless of whether source
files have changed.
- recompile=never
- Never recompile object files.
- recompile=check (default)
- Recompile an object file if a source file that it depends
on has changed.
Additionally, if getProperties().getProperty("compiler."
+ key) == value , then files are
compiled with a compiler such that
compiler.getProperty(key) ==
value .
a Properties |
getScriptStream | public synchronized InputStream getScriptStream(String pathname, Properties props) throws CompilationError, IOException(Code) | | Returns an InputStream containing the script form of the file
named by pathname, suitable play on the client.
Parameters: pathname - a String value. Ifpathname is relative, it is resolved relative to theCompilationManager's sourceDirectory. Parameters: props - params for dependency tracker and compiler the compiled File object. exception: CompilationError - if an error occurs. |
isItemUpToDate | public boolean isItemUpToDate(Item item, String pathname, Properties props) throws CompilationError(Code) | | true if the item is up to date Parameters: pathname - a String value. Ifpathname is relative, it is resolved relative to theCompilationManager's sourceDirectory. Parameters: props - properties that affect the compile. the bytes of the object file exception: CompilationError - if an error occursThe PROPS parameter may contain - "Content-Encoding" => the encoding of the output (ignore if null)
NOTE: can remove the recompile property from props |
setSourceDirectory | public void setSourceDirectory(File sourceDirectory)(Code) | | Sets the source directory. This is the directory within which
source files will be searched for.
Parameters: sourceDirectory - a File |
|
|