org.mmbase.cache.xslt
Class TemplateCache

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended byorg.mmbase.util.LRUHashtable
              extended byorg.mmbase.cache.Cache
                  extended byorg.mmbase.cache.xslt.TemplateCache
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable, SizeMeasurable

public class TemplateCache
extends Cache

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,v 1.11 2003/07/17 17:01:17 michiel Exp $
Author:
Michiel Meeuwissen
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.mmbase.util.LRUHashtable
LRUHashtable.LRUEntry, LRUHashtable.LRUEntrySet, LRUHashtable.LRUEntrySetIterator
 
Field Summary
 
Fields inherited from class org.mmbase.cache.Cache
maxEntrySize
 
Method Summary
static TemplateCache getCache()
          Returns the Template cache.
 java.lang.String getDescription()
          Gives a description for this cache type.
 java.lang.String getName()
          Returns a name for this cache type.
 javax.xml.transform.Templates getTemplates(javax.xml.transform.Source src)
           
 javax.xml.transform.Templates getTemplates(javax.xml.transform.Source src, javax.xml.transform.URIResolver uri)
           
static void main(java.lang.String[] argv)
          Invocation of the class from the commandline for testing
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          You can only put Source/Templates values in the cache, so this throws an Exception.
 java.lang.Object put(javax.xml.transform.Source src, javax.xml.transform.Templates value)
           
 java.lang.Object put(javax.xml.transform.Source src, javax.xml.transform.Templates value, javax.xml.transform.URIResolver uri)
           
 java.lang.Object remove(java.lang.Object key)
          When removing an entry (because of LRU e.g), then also the FileWatchter must be removed.
 
Methods inherited from class org.mmbase.cache.Cache
get, getByteSize, getByteSize, getCache, getCaches, getDefaultMaxEntrySize, getMaxEntrySize, getTotalByteSize, isActive, putCache, putCache, setActive
 
Methods inherited from class org.mmbase.util.LRUHashtable
clear, clone, elements, entrySet, getCount, getHits, getMisses, getOrderedElements, getOrderedElements, getOrderedEntries, getOrderedEntries, getPuts, getRatio, getSize, getStats, keySet, setSize, size, toString, toString, values
 
Methods inherited from class java.util.Hashtable
contains, containsKey, containsValue, equals, hashCode, isEmpty, keys, putAll, rehash
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getCache

public static TemplateCache getCache()
Returns the Template cache.


getName

public java.lang.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.

Overrides:
getName in class Cache

getDescription

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

Overrides:
getDescription in class Cache

getTemplates

public javax.xml.transform.Templates getTemplates(javax.xml.transform.Source src)

getTemplates

public javax.xml.transform.Templates getTemplates(javax.xml.transform.Source src,
                                                  javax.xml.transform.URIResolver uri)

remove

public java.lang.Object remove(java.lang.Object key)
When removing an entry (because of LRU e.g), then also the FileWatchter must be removed.

Specified by:
remove in interface java.util.Map
Overrides:
remove in class LRUHashtable
Parameters:
key - the key of the element
Returns:
the original value of the element if it existed, null if it could not be found

put

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

Specified by:
put in interface java.util.Map
Overrides:
put in class Cache
Throws:
java.lang.RuntimeException

put

public java.lang.Object put(javax.xml.transform.Source src,
                            javax.xml.transform.Templates value)

put

public java.lang.Object put(javax.xml.transform.Source src,
                            javax.xml.transform.Templates value,
                            javax.xml.transform.URIResolver uri)

main

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



MMBase build 1.7.1.20041002