org.cdlib.xtf.servletBase
Class StylesheetCache
Object
Cache<K,V>
GeneratingCache
StylesheetCache
public class StylesheetCache
- extends GeneratingCache
This class is used to cache stylesheets so they don't have to be
reloaded each time they're used.
Constructor Summary |
StylesheetCache(int maxEntries,
int maxTime,
boolean dependencyChecking)
Constructor. |
Method Summary |
void |
enableProfiling(StylesheetCache.TraceListenerFactory tlf)
Enable or disable profiling (only affects stylesheets that are
not already cached). |
Templates |
find(String path)
Locate the stylesheet for the given filesystem path. |
protected Object |
generate(Object key)
Load and parse a stylesheet from the filesystem. |
protected void |
logAction(String action,
Object key,
Object value)
Prints out useful debugging info |
Methods inherited from class Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
dependencyChecking
private boolean dependencyChecking
dependencyReceiver
private GeneratingCache dependencyReceiver
traceListenerFactory
private StylesheetCache.TraceListenerFactory traceListenerFactory
factory
private TransformerFactory factory
StylesheetCache
public StylesheetCache(int maxEntries,
int maxTime,
boolean dependencyChecking)
- Constructor.
- Parameters:
maxEntries
- Max # of entries before old ones are flushedmaxTime
- Max age (in seconds) before an entry is flushed.dependencyChecking
- Whether to keep track of dependencies and
invalidate cache entries when dependents
are updated.
find
public Templates find(String path)
throws Exception
- Locate the stylesheet for the given filesystem path. If not cached,
then load it.
- Parameters:
path
- Filesystem path of the stylesheet to load
- Returns:
- The parsed stylesheet
- Throws:
Exception
- If the stylesheet could not be loaded.
enableProfiling
public void enableProfiling(StylesheetCache.TraceListenerFactory tlf)
- Enable or disable profiling (only affects stylesheets that are
not already cached). If the factory is null, profiling is
disabled.
generate
protected Object generate(Object key)
throws Exception
- Load and parse a stylesheet from the filesystem.
- Specified by:
generate
in class GeneratingCache
- Parameters:
key
- (String)Filesystem path of the stylesheet to load
- Returns:
- The parsed stylesheet
- Throws:
Exception
- If the stylesheet could not be loaded.
logAction
protected void logAction(String action,
Object key,
Object value)
- Prints out useful debugging info
- Overrides:
logAction
in class Cache
- Parameters:
action
- What happened ("Added", "Removed", etc.)key
- The key involved in the actionvalue
- The value involved in the action