org.norther.tammi.spray.servlet
Class DefaultServletEngine

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.servlet.DefaultServletEngine
All Implemented Interfaces:
Serializable, EventListener, NotificationBroadcaster, NotificationEmitter, TraceListener, Manageable, MBeanDelegate, Refreshable, Startable, CacheClient, Configurable, TemplateEngine, ServletEngine
Direct Known Subclasses:
DefaultJSPEngine

public class DefaultServletEngine
extends AbstractTemplateEngine
implements ServletEngine

DefaultServletEngine implements TemplateEngine for servlet templates.

Author:
Ilkka Priha
See Also:
Serialized Form

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.spray.servlet.ServletEngine
CONTEXT_NAME_PROPERTY, FOLDER_PATHS_PROPERTY, FORWARDED_PROPERTY, TEMPLATE_KEY_PROPERTY
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
DefaultServletEngine()
          Constructs a new engine.
 
Method Summary
 void addFolderPath(int index, String path)
          Adds a template folder path at the specified index.
 void addFolderPath(String path)
          Adds a template folder path.
protected  void checkProperties()
          Checks properties.
 void clearFolders()
          Clears all template folders.
protected  void dispatch(String path, TemplateContext context, ServletRequest request, ServletResponse response, Writer writer)
          Dispatches the specified template path.
 ObjectName getContextName()
          Gets the startup context name.
 String[] getFolderPaths()
          Gets the template folder paths.
 String getTemplateKey()
          Gets the path finder key for resolving template paths.
 boolean isForwarded()
          Gets the forwarded option.
 void postmanaged()
          This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.
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 removeFolderPath(String path)
          Removes a template folder path.
 void setContextName(ObjectName name)
          Sets the startup context name.
 void setFolderPaths(String[] paths)
          Sets the template folder paths.
 void setForwarded(boolean option)
          Sets the forwarded option.
 void setTemplateKey(String key)
          Sets the path finder key for resolving template paths.
 boolean templateExists(String template)
          Checks whether a specific template exists.
 void unmanaged()
          This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.
protected  void updateProperties()
          Updates properties.
 
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, start, stop
 
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, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, 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.spray.engine.TemplateEngine
evaluate, evaluate, evaluate, execute, execute, execute, getDefaultEncoding, resolveLocalizedTemplate, setDefaultEncoding
 
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
 
Methods inherited from interface org.norther.tammi.core.cache.CacheClient
clearCached, expireCached, expireFraction, getCache, isCachingDisabled, removeCache, setCachingDisabled
 
Methods inherited from interface org.norther.tammi.core.base.Refreshable
getRefreshed, refresh
 
Methods inherited from interface org.norther.tammi.core.base.Startable
isStarted, start, stop
 

Constructor Detail

DefaultServletEngine

public DefaultServletEngine()
Constructs a new engine.

Method Detail

postmanaged

public void postmanaged()
Description copied from interface: Manageable
This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.

Specified by:
postmanaged in interface Manageable
Overrides:
postmanaged in class Adaptee

unmanaged

public void unmanaged()
               throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.

Specified by:
unmanaged in interface Manageable
Overrides:
unmanaged in class Adaptee
Throws:
Exception - if the adaptee refused to be unmanaged.

getTemplateKey

public String getTemplateKey()
Description copied from interface: ServletEngine
Gets the path finder key for resolving template paths.

Specified by:
getTemplateKey in interface ServletEngine
Returns:
the path finder key.

setTemplateKey

public void setTemplateKey(String key)
Description copied from interface: ServletEngine
Sets the path finder key for resolving template paths. The default key is PathFinder.TEMPLATE.

Specified by:
setTemplateKey in interface ServletEngine
Parameters:
key - the path finder key.

isForwarded

public boolean isForwarded()
Description copied from interface: ServletEngine
Gets the forwarded option.

Specified by:
isForwarded in interface ServletEngine
Returns:
true if the forwarded option is set, otherwise false.

setForwarded

public void setForwarded(boolean option)
Description copied from interface: ServletEngine
Sets the forwarded option. If set, incoming requests are forwarded to the JSP servlet, otherwise the JSP template is included in requests.

Specified by:
setForwarded in interface ServletEngine
Parameters:
option - true to set the forwarded option, otherwise false.

getFolderPaths

public String[] getFolderPaths()
Description copied from interface: ServletEngine
Gets the template folder paths.

Specified by:
getFolderPaths in interface ServletEngine
Returns:
an array of folder paths.

setFolderPaths

public void setFolderPaths(String[] paths)
Description copied from interface: ServletEngine
Sets the template folder paths.

Specified by:
setFolderPaths in interface ServletEngine
Parameters:
paths - an array of folder paths.

addFolderPath

public void addFolderPath(String path)
Description copied from interface: ServletEngine
Adds a template folder path.

Specified by:
addFolderPath in interface ServletEngine
Parameters:
path - the folder path.

addFolderPath

public void addFolderPath(int index,
                          String path)
Description copied from interface: ServletEngine
Adds a template folder path at the specified index.

Specified by:
addFolderPath in interface ServletEngine
Parameters:
index - the index.
path - the folder path.

removeFolderPath

public void removeFolderPath(String path)
Description copied from interface: ServletEngine
Removes a template folder path.

Specified by:
removeFolderPath in interface ServletEngine
Parameters:
path - the folder path.

clearFolders

public void clearFolders()
Description copied from interface: ServletEngine
Clears all template folders.

Specified by:
clearFolders in interface ServletEngine

getContextName

public ObjectName getContextName()
Description copied from interface: ServletEngine
Gets the startup context name.

Specified by:
getContextName in interface ServletEngine
Returns:
the name of the context or a query.

setContextName

public void setContextName(ObjectName name)
Description copied from interface: ServletEngine
Sets the startup context name.

Specified by:
setContextName in interface ServletEngine
Parameters:
name - the name of the context or a query.

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.

dispatch

protected void dispatch(String path,
                        TemplateContext context,
                        ServletRequest request,
                        ServletResponse response,
                        Writer writer)
                 throws IOException,
                        ServletException
Dispatches the specified template path.

Parameters:
path - the resolved template path.
context - the template context.
request - the servlet request.
response - the servlet response.
writer - the content writer.
Throws:
IOException - on I/O errors.
ServletException - on servlet errors.

checkProperties

protected void checkProperties()
Checks properties.


updateProperties

protected void updateProperties()
Updates properties.



Copyright © 2004 The Norther Organization. All rights reserved.