org.webmacro.servlet
Class TemplateTool

java.lang.Object
  |
  +--org.webmacro.servlet.TemplateTool
All Implemented Interfaces:
ContextTool

public class TemplateTool
extends java.lang.Object
implements ContextTool

This is an experimental context tool that allows templates to be used as macros. The tool places a MacroTemplateFactory instance into the context that can be referenced as $Template in WMScript. The factory has two methods, each of which returns a MacroTemplate object, created either from a string or a file.

Version:
0.2
Author:
Keats Kirsch

Inner Class Summary
 class TemplateTool.MacroTemplate
          Encapsulates a template and a context, allowing a template to be used like a function or "macro".
 class TemplateTool.MacroTemplateFactory
          A factory class for creating MacroTemplate objects.
 
Constructor Summary
TemplateTool()
          Creates new TemplateTool
 
Method Summary
 void destroy(java.lang.Object o)
          Invoked when the context is freed after its request/response has been completed.
 java.lang.Object init(Context c)
          Create a factory object that can be accessed from WMScript as $Template for creating MacroTemplate objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateTool

public TemplateTool()
Creates new TemplateTool
Method Detail

destroy

public void destroy(java.lang.Object o)
Invoked when the context is freed after its request/response has been completed. Used here to free the contexts created for MacroTemplates in this request.
Specified by:
destroy in interface ContextTool
Parameters:
o - the MacroTemplateFactory that is ready to be destroyed.

init

public java.lang.Object init(Context c)
                      throws PropertyException
Create a factory object that can be accessed from WMScript as $Template for creating MacroTemplate objects.
Specified by:
init in interface ContextTool
Parameters:
c - The context of the current request.
Returns:
a new MacroTemplateFactory for each request.
Throws:
PropertyException - From the ContextTool interface