org.thymeleaf.cache
Class AbstractCacheManager

Object
  extended by org.thymeleaf.cache.AbstractCacheManager
All Implemented Interfaces:
ICacheManager
Direct Known Subclasses:
StandardCacheManager

public abstract class AbstractCacheManager
extends Object
implements ICacheManager

Common abstract class for ICacheManager implementations, useful for taking care of the lazy initialization of cache objects when their corresponding getXCache() methods are called.

Since:
2.0.0
Author:
Daniel Fernández

Constructor Summary
AbstractCacheManager()
           
 
Method Summary
 ICache<String,Object> getExpressionCache()
           Returns the cache of expression evaluation artifacts.
 ICache<String,java.util.List<Node>> getFragmentCache()
           Returns the cache of template code fragments.
 ICache<String,java.util.Properties> getMessageCache()
           Returns the cache used for externalized/internationalized messages.
<K,V> ICache<K,V>
getSpecificCache(String name)
           Returns a specific (non-default) cache, by its name.
 ICache<String,Template> getTemplateCache()
           Returns the cache of parsed templates.
protected abstract  ICache<String,Object> initializeExpressionCache()
           
protected abstract  ICache<String,java.util.List<Node>> initializeFragmentCache()
           
protected abstract  ICache<String,java.util.Properties> initializeMessageCache()
           
protected abstract  ICache<String,Template> initializeTemplateCache()
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCacheManager

public AbstractCacheManager()
Method Detail

getTemplateCache

public final ICache<String,Template> getTemplateCache()
Description copied from interface: ICacheManager

Returns the cache of parsed templates. Keys are the template names, as specified at the TemplateEngine.process(String, org.thymeleaf.context.IContext) method.

Specified by:
getTemplateCache in interface ICacheManager
Returns:
the cache of parsed templates.

getFragmentCache

public final ICache<String,java.util.List<Node>> getFragmentCache()
Description copied from interface: ICacheManager

Returns the cache of template code fragments. These fragments are pieces of template code that need to be parsed before adding them to the template DOM being processed.

Typical examples of these fragments are externalized/internationalized messages like:

home.header=Welcome to the <i>fruit market</i>!

...which are used in templates like th:utext="#{home.header}", and therefore need parsing in order to be converted to a DOM subtree (because that "<i>" should be a DOM element by itself).

Keys in this cache are the String representation of fragments themselves along with the template mode used for such parsing (like "{HTML5}Welcome to the <i>fruit market</i>"), and values are the list of DOM Nodes that correspond to parsing each fragment.

Important: this fragments are not related to th:fragment processors.

Specified by:
getFragmentCache in interface ICacheManager
Returns:
the cache of parsed template code fragments

getMessageCache

public final ICache<String,java.util.Properties> getMessageCache()
Description copied from interface: ICacheManager

Returns the cache used for externalized/internationalized messages.

This cache uses as keys the template names (as specified at TemplateEngine.process(String, org.thymeleaf.context.IContext)) along with the locale the messages refer to (like "main_gl_ES"), and as values the Properties object containing the messages.

Specified by:
getMessageCache in interface ICacheManager
Returns:
the message cache

getExpressionCache

public final ICache<String,Object> getExpressionCache()
Description copied from interface: ICacheManager

Returns the cache of expression evaluation artifacts.

This cache is meant to store artifacts of diverse nature needed along the process of parsing and executing expressions in the several languages available: Standard expressions, OGNL expressions, Spring EL expressions...

Parsing these expressions usually results in some kind of syntax tree object that represents the expression, and this is what this cache usually stores.

Keys are the expressions themselves (their String representation), along with a prefix that is normally used for identifying the nature of the object being cached (for example "{OGNL}person.name").

Specified by:
getExpressionCache in interface ICacheManager
Returns:
the cache of expression artifacts

getSpecificCache

public <K,V> ICache<K,V> getSpecificCache(String name)
Description copied from interface: ICacheManager

Returns a specific (non-default) cache, by its name.

User-defined dialects might make use of additional caches (besides template, fragment, message and expression) defined at custom-made implementations of this interface, and they should use this method to retrieve them by their name.

Specified by:
getSpecificCache in interface ICacheManager
Parameters:
name - the name of the needed cache
Returns:
the required cache

initializeTemplateCache

protected abstract ICache<String,Template> initializeTemplateCache()

initializeFragmentCache

protected abstract ICache<String,java.util.List<Node>> initializeFragmentCache()

initializeMessageCache

protected abstract ICache<String,java.util.Properties> initializeMessageCache()

initializeExpressionCache

protected abstract ICache<String,Object> initializeExpressionCache()


Copyright © 2012 The THYMELEAF team. All Rights Reserved.