org.norther.tammi.spray.freemarker
Class FreemarkerEngine

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.config.DefaultConfigurable
          extended by org.norther.tammi.spray.engine.AbstractTemplateEngine
              extended by org.norther.tammi.spray.freemarker.FreemarkerEngine
All Implemented Interfaces:
Serializable, EventListener, NotificationBroadcaster, NotificationEmitter, TraceListener, Manageable, MBeanDelegate, Refreshable, Startable, CacheClient, Configurable, TemplateEngine

public class FreemarkerEngine
extends AbstractTemplateEngine

FreemarkerEngine implements TemplateEngine for Freemarker templates.

Note that changes to engine configuration require a restart to become effective.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
static String FREEMARKER_PROPERTY_PREFIX
          The freemarker property prefix.
static String LOGGER_NAME_PREFIX
          The logger name prefix.
static String RESOURCE_LOADER_CLASS_PROPERTY
          The resource loader class property.
static String RESOURCE_LOADER_FINDER_PROPERTY
          The resource loader finder property.
static String RESOURCE_LOADER_KEY_PROPERTY
          The resource loader key property.
static String RESOURCE_LOADER_PATH_PROPERTY
          The resource loader path property.
static String RESOURCE_LOADER_PROPERTY
          The resource loader property.
 
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
FreemarkerEngine()
          Constructs a new engine.
 
Method Summary
protected  Configuration getFreemarker()
          Gets the Freemarker configuration.
protected  DefaultTemplateLoader getTemplateLoader()
          Gets the template loader.
protected  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 start()
          Starts the MBean.
 void stop()
          Stops the MBean.
 boolean templateExists(String template)
          Checks whether a specific template exists.
 
Methods inherited from class org.norther.tammi.spray.engine.AbstractTemplateEngine
clearCached, evaluate, evaluate, evaluate, execute, execute, execute, expireCached, expireFraction, getCache, getDefaultEncoding, getRefreshed, getTemplateEncoding, isCachingDisabled, isStarted, refresh, removeCache, resolveLocalizedTemplate, setCachingDisabled, setDefaultEncoding
 
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
 

Field Detail

FREEMARKER_PROPERTY_PREFIX

public static final String FREEMARKER_PROPERTY_PREFIX
The freemarker property prefix.

See Also:
Constant Field Values

RESOURCE_LOADER_PROPERTY

public static final String RESOURCE_LOADER_PROPERTY
The resource loader property.

See Also:
Constant Field Values

RESOURCE_LOADER_CLASS_PROPERTY

public static final String RESOURCE_LOADER_CLASS_PROPERTY
The resource loader class property.

See Also:
Constant Field Values

RESOURCE_LOADER_KEY_PROPERTY

public static final String RESOURCE_LOADER_KEY_PROPERTY
The resource loader key property.

See Also:
Constant Field Values

RESOURCE_LOADER_FINDER_PROPERTY

public static final String RESOURCE_LOADER_FINDER_PROPERTY
The resource loader finder property.

See Also:
Constant Field Values

RESOURCE_LOADER_PATH_PROPERTY

public static final String RESOURCE_LOADER_PATH_PROPERTY
The resource loader path property.

See Also:
Constant Field Values

LOGGER_NAME_PREFIX

public static final String LOGGER_NAME_PREFIX
The logger name prefix.

See Also:
Constant Field Values
Constructor Detail

FreemarkerEngine

public FreemarkerEngine()
Constructs a new engine.

Method Detail

start

public void start()
           throws Exception
Description copied from interface: Startable
Starts the MBean.

Specified by:
start in interface Startable
Overrides:
start in class AbstractTemplateEngine
Throws:
Exception - if start fails.

stop

public void stop()
Description copied from interface: Startable
Stops the MBean.

Specified by:
stop in interface Startable
Overrides:
stop in class AbstractTemplateEngine

templateExists

public boolean templateExists(String template)
Description copied from interface: TemplateEngine
Checks whether a specific template exists.

Specified by:
templateExists in interface TemplateEngine
Specified by:
templateExists in class AbstractTemplateEngine
Parameters:
template - the name of the template.
Returns:
true, if the template is available.

process

protected void process(CharSequence content,
                       TemplateContext context,
                       String template,
                       String encoding,
                       Writer writer)
                throws TemplateException
Description copied from class: AbstractTemplateEngine
Subclasses implement this method to process the specified run-time content or target template.

Note that implementations should catch TemplateBreakExceptions.

Specified by:
process in class AbstractTemplateEngine
Parameters:
content - optional run-time content.
context - the template context.
template - the target template.
encoding - the template encoding.
writer - the content writer.
Throws:
TemplateException - on errors.

getTemplateLoader

protected DefaultTemplateLoader getTemplateLoader()
Gets the template loader.

Returns:
the template loader.

getFreemarker

protected Configuration getFreemarker()
Gets the Freemarker configuration.

Returns:
the configuration.


Copyright © 2004 The Norther Organization. All rights reserved.