|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ICacheManager
Common interface for all cache manager implementations.
This class is in charge of providing the corresponding cache objects to the template engine. Every call to each of the getXCache() methods must always return the XCache object (i.e. only one cache object should be ever created for each type of cache, and returned every time it is requested).
Four caches are predefined:
Expression
parsed trees,
OGNL/Spring EL parsed trees, etc). Given that this cache can usually store objects
of different classes (referenced by their String representation), prefixes are
normally applied to the String keys in order to being able to differentiate these
differente classes when retrieving cache entries.
Only these four caches are needed by the template engine when the standard dialects
are being used, but users might want to define new dialects and use new types of caches,
which can be provided by the cache manager using the getSpecificCache(String)
method.
Any of these methods could return null, in which case the engine will consider that no cache must be applied for that specific function.
Method Summary | ||
---|---|---|
ICache<String,Object> |
getExpressionCache()
Returns the cache of expression evaluation artifacts. |
|
ICache<String,List<Node>> |
getFragmentCache()
Returns the cache of template code fragments. |
|
ICache<String,Properties> |
getMessageCache()
Returns the cache used for externalized/internationalized messages. |
|
|
getSpecificCache(String name)
Returns a specific (non-default) cache, by its name. |
|
ICache<String,Template> |
getTemplateCache()
Returns the cache of parsed templates. |
Method Detail |
---|
ICache<String,Template> getTemplateCache()
Returns the cache of parsed templates. Keys are the template names,
as specified at the TemplateEngine.process(String, org.thymeleaf.context.IContext)
method.
ICache<String,List<Node>> getFragmentCache()
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 Node
s that correspond to parsing each fragment.
Important: this fragments are not related to th:fragment processors.
ICache<String,Properties> getMessageCache()
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.
ICache<String,Object> getExpressionCache()
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").
<K,V> ICache<K,V> getSpecificCache(String name)
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.
name
- the name of the needed cache
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |