org.norther.tammi.spray.velocity
Class VelocityEngine

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.velocity.VelocityEngine
All Implemented Interfaces:
Serializable, EventListener, NotificationBroadcaster, NotificationEmitter, TraceListener, Manageable, MBeanDelegate, Refreshable, Startable, CacheClient, Configurable, TemplateEngine

public class VelocityEngine
extends AbstractTemplateEngine

VelocityEngine implements TemplateEngine for Velocity templates.

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

Based on TurbineVelocityEngine in the Apache Jakarta Turbine project.

Author:
Dave Bryson, Rafal Krzewski, Jason van Zyl, Sean Legassick, Daniel Rall, Ilkka Priha
See Also:
Serialized Form

Field Summary
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.
static String TEMPLATE_ENGINE_PROPERTY
          The template engine 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
VelocityEngine()
          Constructs a new engine.
 
Method Summary
protected  org.apache.velocity.app.VelocityEngine getEngine()
          Gets the Velocity engine.
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

TEMPLATE_ENGINE_PROPERTY

public static final String TEMPLATE_ENGINE_PROPERTY
The template engine property.

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_KEY_PROPERTY

public static final String RESOURCE_LOADER_KEY_PROPERTY
The resource loader key 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

RESOURCE_LOADER_FINDER_PROPERTY

public static final String RESOURCE_LOADER_FINDER_PROPERTY
The resource loader finder property.

See Also:
Constant Field Values
Constructor Detail

VelocityEngine

public VelocityEngine()
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.

getEngine

protected org.apache.velocity.app.VelocityEngine getEngine()
Gets the Velocity engine.

Returns:
the engine.


Copyright © 2004 The Norther Organization. All rights reserved.