org.mmbase.cache.xslt
Class TemplateCache

java.lang.Object
  extended by org.mmbase.cache.Cache<TemplateCache.Key,Templates>
      extended by org.mmbase.cache.xslt.TemplateCache
All Implemented Interfaces:
Map<TemplateCache.Key,Templates>, CacheMBean, SizeMeasurable

public class TemplateCache
extends Cache<TemplateCache.Key,Templates>

A cache for XSL transformation templates. A template can be based on a file, or on a string. In the first case the cache key is based on the file name, and the cache entry is invalidated if the file changes (so, if you uses 'imports' in the XSL template, you have to touch the file which imports, if the imported files changes). If the template is based on a string, then the string itself serves as a key.

Since:
MMBase-1.6
Version:
$Id: TemplateCache.java 41989 2010-04-20 16:45:39Z michiel $
Author:
Michiel Meeuwissen

Nested Class Summary
static class TemplateCache.Key
          Object to use as a key in the Caches.
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class org.mmbase.cache.Cache
lock, maxEntrySize
 
Method Summary
 void clear()
           
static TemplateCache getCache()
          Returns the Template cache.
 String getDescription()
          Gives a description for this cache type.
 String getName()
          Returns a name for this cache type.
 Templates getTemplates(Source src)
           
 Templates getTemplates(Source src, URIResolver uri)
           
static void main(String[] argv)
          Invocation of the class from the commandline for testing
 Templates put(Source src, Templates value)
           
 Templates put(Source src, Templates value, URIResolver uri)
           
 Templates put(TemplateCache.Key key, Templates value)
          You can only put Source/Templates values in the cache, so this throws an Exception.
 Templates remove(Object o)
          When removing an entry then also the FileWatcher must be removed.
 
Methods inherited from class org.mmbase.cache.Cache
checkCachePolicy, contains, containsKey, containsValue, entrySet, equals, get, getAvarageValueLength, getByteSize, getByteSize, getCheapByteSize, getCount, getDefaultMaxEntrySize, getHits, getImplementation, getLock, getMaxEntrySize, getMaxSize, getMisses, getPuts, getRatio, getSize, getStats, hashCode, isActive, isEmpty, keySet, maxSize, putAll, putCache, reset, setActive, setMaxEntrySize, setMaxSize, size, toString, values
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getCache

public static TemplateCache getCache()
Returns the Template cache.


getName

public String getName()
Description copied from class: Cache
Returns a name for this cache type. Default it is the class name, but this normally will be overriden.

Specified by:
getName in interface CacheMBean
Overrides:
getName in class Cache<TemplateCache.Key,Templates>

getDescription

public String getDescription()
Description copied from class: Cache
Gives a description for this cache type. This can be used in cache overviews.

Specified by:
getDescription in interface CacheMBean
Overrides:
getDescription in class Cache<TemplateCache.Key,Templates>

getTemplates

public Templates getTemplates(Source src)

getTemplates

public Templates getTemplates(Source src,
                              URIResolver uri)

remove

public Templates remove(Object o)
When removing an entry then also the FileWatcher must be removed.

Specified by:
remove in interface Map<TemplateCache.Key,Templates>
Overrides:
remove in class Cache<TemplateCache.Key,Templates>
See Also:
Map.remove(java.lang.Object)
To Do:
When the cache shrinks because of LRU, or other operations done directly on the operation, this method of course is not called.

clear

public void clear()
Specified by:
clear in interface Map<TemplateCache.Key,Templates>
Specified by:
clear in interface CacheMBean
Overrides:
clear in class Cache<TemplateCache.Key,Templates>
See Also:
Map.clear()

put

public Templates put(TemplateCache.Key key,
                     Templates value)
You can only put Source/Templates values in the cache, so this throws an Exception.

Specified by:
put in interface Map<TemplateCache.Key,Templates>
Overrides:
put in class Cache<TemplateCache.Key,Templates>
Throws:
RuntimeException

put

public Templates put(Source src,
                     Templates value)

put

public Templates put(Source src,
                     Templates value,
                     URIResolver uri)

main

public static void main(String[] argv)
Invocation of the class from the commandline for testing



MMBase 2.0-SNAPSHOT - null