|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.norther.tammi.core.base.Adaptee org.norther.tammi.core.config.DefaultConfigurable org.norther.tammi.spray.engine.AbstractTemplateEngine<K,V>
K
- the cache key type.V
- the cache value type.public abstract class AbstractTemplateEngine<K,V>
An abstract implementation of TemplateEngine.
Based on BaseTemplateEngineService
in the Apache Jakarta Turbine
project.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.norther.tammi.core.config.DefaultConfigurable |
---|
DefaultConfigurable.Modified |
Field Summary |
---|
Fields inherited from class org.norther.tammi.core.base.Adaptee |
---|
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS |
Constructor Summary | |
---|---|
AbstractTemplateEngine()
Constructs a new engine. |
Method Summary | |
---|---|
void |
clearCached()
Clears all cached entries without notifying. |
CharSequence |
evaluate(CharSequence content,
TemplateContext context,
String template)
Evaluates the given run-time content. |
CharSequence |
evaluate(TemplateContext context,
String template)
Evaluates the specified template. |
CharSequence |
evaluate(TemplateContext context,
String template,
String encoding)
Evaluates the specified template using the given encoding. |
void |
execute(CharSequence content,
TemplateContext context,
String template,
Writer writer)
Executes the given run-time content. |
void |
execute(TemplateContext context,
String template,
String encoding,
Writer writer)
Executes the specified template using the given encoding. |
void |
execute(TemplateContext context,
String template,
Writer writer)
Executes the specified template. |
void |
expireCached(long timestamp)
Expires all cached entries notifying them about expiration. |
void |
expireFraction(long timestamp,
float fraction)
Expires the specified fraction of cached entries notifying them about expiration. |
ConcurrentMap<K,V> |
getCache(boolean... create)
Gets and optionally creates the cache. |
String |
getDefaultEncoding()
Gets the default encoding to apply when not explicitly specified. |
long |
getRefreshed()
Gets the last refresh timestamp. |
ObjectName |
getSharedCacheName()
Gets the the shared cache of this client. |
protected String |
getTemplateEncoding(String template)
Gets the template encoding for the speficied template. |
boolean |
isCachingDisabled()
Checks whether the caching is disabled. |
boolean |
isStarted()
Checks whether the startable has been started. |
protected abstract void |
process(CharSequence content,
TemplateContext context,
String template,
String encoding,
Writer writer)
Subclasses implement this method to process the specified run-time content or target template. |
void |
refresh()
Refreshes the MBean. |
void |
removeCache()
Removes the cache. |
String |
resolveLocalizedTemplate(String template,
Locale locale)
Resolves a localized template name. |
void |
setCachingDisabled(boolean flag)
Sets the caching disabled flag. |
void |
setDefaultEncoding(String encoding)
Sets the default encoding to apply when not explicitly specified. |
void |
setSharedCacheName(ObjectName cache)
Sets the shared cache of this client. |
void |
start()
Starts the MBean. |
void |
stop()
Stops the MBean. |
abstract boolean |
templateExists(String template)
Checks whether a specific template exists. |
Methods inherited from class org.norther.tammi.core.base.Adaptee |
---|
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, postmanaged, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unmanaged, unregister |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.norther.tammi.core.config.Configurable |
---|
addProperty, addProperty, addPropertyFilePath, addPropertyFilePath, clearProperties, containsProperty, getConfigKey, getProperties, getProperty, getPropertyFilePath, getPropertyFilePaths, indexOfProperty, propertyMap, propertyMap, removeProperty, removeProperty, removePropertyFilePath, setConfigKey, setProperties, setProperty, setPropertyFilePath, setPropertyFilePath, setPropertyFilePaths, setPropertyFilePaths, storeProperties |
Constructor Detail |
---|
public AbstractTemplateEngine()
Method Detail |
---|
public boolean isCachingDisabled()
CacheClient
isCachingDisabled
in interface CacheClient<K,V>
public void setCachingDisabled(boolean flag)
CacheClient
setCachingDisabled
in interface CacheClient<K,V>
flag
- the caching disabled flag.public void expireCached(long timestamp)
CacheClient
expireCached
in interface CacheClient<K,V>
timestamp
- the timestamp of the expiration.public void expireFraction(long timestamp, float fraction)
CacheClient
expireFraction
in interface CacheClient<K,V>
timestamp
- the timestamp of the expiration.fraction
- the fraction of entries to expire (0.0..1.0).public void clearCached()
CacheClient
clearCached
in interface CacheClient<K,V>
public ConcurrentMap<K,V> getCache(boolean... create)
CacheClient
getCache
in interface CacheClient<K,V>
create
- true to create a missing cache.
public void removeCache()
CacheClient
removeCache
in interface CacheClient<K,V>
public ObjectName getSharedCacheName()
CacheClient
getSharedCacheName
in interface CacheClient<K,V>
public void setSharedCacheName(ObjectName cache)
CacheClient
setSharedCacheName
in interface CacheClient<K,V>
cache
- the object name of the shared cache or a query.public void refresh()
Refreshable
refresh
in interface Refreshable
public long getRefreshed()
Refreshable
getRefreshed
in interface Refreshable
public boolean isStarted()
Startable
isStarted
in interface Startable
public void start() throws Exception
Startable
start
in interface Startable
Exception
- if start fails.public void stop()
Startable
stop
in interface Startable
public String getDefaultEncoding()
TemplateEngine
getDefaultEncoding
in interface TemplateEngine
public void setDefaultEncoding(String encoding)
TemplateEngine
setDefaultEncoding
in interface TemplateEngine
encoding
- the default encoding.public abstract boolean templateExists(String template)
TemplateEngine
templateExists
in interface TemplateEngine
template
- the name of the template.
public String resolveLocalizedTemplate(String template, Locale locale)
TemplateEngine
resolveLocalizedTemplate
in interface TemplateEngine
template
- the name of the template.locale
- the locale to apply.
public CharSequence evaluate(CharSequence content, TemplateContext context, String template) throws TemplateException
TemplateEngine
evaluate
in interface TemplateEngine
content
- the content.context
- the context.template
- a virtual template for identifying the content.
TemplateException
- if processing fails.public CharSequence evaluate(TemplateContext context, String template) throws TemplateException
TemplateEngine
evaluate
in interface TemplateEngine
context
- the context.template
- the name of the template.
TemplateException
- if processing fails.public CharSequence evaluate(TemplateContext context, String template, String encoding) throws TemplateException
TemplateEngine
evaluate
in interface TemplateEngine
context
- the context.template
- the name of the template.encoding
- an optional template encoding.
TemplateException
- if processing fails.public void execute(CharSequence content, TemplateContext context, String template, Writer writer) throws TemplateException
TemplateEngine
execute
in interface TemplateEngine
content
- the content.context
- the context.template
- a virtual template for identifying the content.writer
- a writer for the result.
TemplateException
- if processing fails.public void execute(TemplateContext context, String template, Writer writer) throws TemplateException
TemplateEngine
execute
in interface TemplateEngine
context
- the context.template
- the name of the template.writer
- a writer for the result.
TemplateException
- if processing fails.public void execute(TemplateContext context, String template, String encoding, Writer writer) throws TemplateException
TemplateEngine
execute
in interface TemplateEngine
context
- the context.template
- the name of the template.encoding
- an optional template encoding.writer
- a writer for the result.
TemplateException
- if processing fails.protected abstract void process(CharSequence content, TemplateContext context, String template, String encoding, Writer writer) throws TemplateException
Note that implementations should catch TemplateBreakExceptions.
content
- optional run-time content.context
- the template context.template
- the target template.encoding
- the template encoding.writer
- the content writer.
TemplateException
- on errors.protected String getTemplateEncoding(String template)
template
- the (localized) name of the template.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |