|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.norther.tammi.core.base.Adaptee
org.norther.tammi.core.config.DefaultConfigurable
org.norther.tammi.spray.engine.AbstractTemplateEngine
public abstract class AbstractTemplateEngine
An abstract implementation of TemplateEngine.
Based on BaseTemplateEngineService in the Apache Jakarta
Turbine project.
| Field Summary |
|---|
| Fields inherited from class org.norther.tammi.core.config.DefaultConfigurable |
|---|
MODIFIED, SYNCHRONIZED, UNMODIFIED |
| Fields inherited from class org.norther.tammi.core.base.Adaptee |
|---|
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS |
| Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate |
|---|
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE |
| 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 |
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. |
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 |
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.config.DefaultConfigurable |
|---|
addProperty, addProperty, clearProperties, containsProperty, getConfigKey, getConfiguration, getModifiedState, getProperties, getProperty, getPropertyFilePath, indexOfProperty, loadConfiguration, loadConfiguration, loadConfiguration, modified, propertyMap, propertyMap, removeProperty, removeProperty, setConfigKey, setModifiedState, setProperties, setProperty, setPropertyFilePath, setPropertyFilePath, storeProperties |
| 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, clearProperties, containsProperty, getConfigKey, getProperties, getProperty, getPropertyFilePath, indexOfProperty, propertyMap, propertyMap, removeProperty, removeProperty, setConfigKey, setProperties, setProperty, setPropertyFilePath, setPropertyFilePath, storeProperties |
| Constructor Detail |
|---|
public AbstractTemplateEngine()
| Method Detail |
|---|
public boolean isCachingDisabled()
CacheClient
isCachingDisabled in interface CacheClientpublic void setCachingDisabled(boolean flag)
CacheClient
setCachingDisabled in interface CacheClientflag - the caching disabled flag.public void expireCached(long timestamp)
CacheClient
expireCached in interface CacheClienttimestamp - the timestamp of the expiration.
public void expireFraction(long timestamp,
float fraction)
CacheClient
expireFraction in interface CacheClienttimestamp - the timestamp of the expiration.fraction - the fraction of entries to expire (0.0..1.0).public void clearCached()
CacheClient
clearCached in interface CacheClientpublic ConcurrentMap getCache(boolean create)
CacheClient
getCache in interface CacheClientcreate - true to create a missing cache.
public void removeCache()
CacheClient
removeCache in interface CacheClientpublic void refresh()
Refreshable
refresh in interface Refreshablepublic long getRefreshed()
Refreshable
getRefreshed in interface Refreshablepublic boolean isStarted()
Startable
isStarted in interface Startable
public void start()
throws Exception
Startable
start in interface StartableException - if start fails.public void stop()
Startable
stop in interface Startablepublic String getDefaultEncoding()
TemplateEngine
getDefaultEncoding in interface TemplateEnginepublic void setDefaultEncoding(String encoding)
TemplateEngine
setDefaultEncoding in interface TemplateEngineencoding - the default encoding.public abstract boolean templateExists(String template)
TemplateEngine
templateExists in interface TemplateEnginetemplate - the name of the template.
public String resolveLocalizedTemplate(String template,
Locale locale)
TemplateEngine
resolveLocalizedTemplate in interface TemplateEnginetemplate - 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 TemplateEnginecontent - 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 TemplateEnginecontext - 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 TemplateEnginecontext - 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 TemplateEnginecontent - 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 TemplateEnginecontext - 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 TemplateEnginecontext - 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 | |||||||||