simple.template
Class TemplateEngine

java.lang.Object
  extended by simple.template.TemplateEngine
All Implemented Interfaces:
ResourceEngine

public class TemplateEngine
extends java.lang.Object
implements ResourceEngine

The TemplateEngine provides the core functionality required to process templates. This provides an implementation of the ResourceEngine interface, and as such is used to acquire resources using a HTTP URI. The Resource objects served by this are loaded and mapped using the mapping functionality found in the MapperEngine. This means that resource implementations, known as services or controllers, can be implemented and placed in a specific directory, and once the objects are referenced they will be loaded and served.

Typically the Resource objects served by this will be implementations of the Action, which enables them to interact with a shared environment. The action services, often referred to as controller services, are similar in concept to a Java Servlets and allow event based request and response objects to be processed.

This requires a Container implementation in order to configure itself. The container provided is used to look for templates and set properties that are accessable to all service objects loaded by this engine, also, properties set with the container will be accessable to all templates processed.

Author:
Niall Gallagher

Constructor Summary
TemplateEngine(Context context, Container system)
          Constructor for the TemplateEngine object.
TemplateEngine(Context context, Container system, java.io.File base)
          Constructor for the TemplateEngine object.
TemplateEngine(Context context, Environment system, java.io.File base)
          Constructor for the TemplateEngine object.
 
Method Summary
 Resource resolve(java.lang.String target)
          This will look for and retrieve the requested resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateEngine

public TemplateEngine(Context context,
                      Container system)
               throws java.lang.Exception
Constructor for the TemplateEngine object. The instance created by this provides a mapping resource engine that loads and instantiates referenced services using the simple.http.load.MapperEngine to resolve the class names for services. Each loaded controller service is instantiated using an Environment object.

Parameters:
context - this is the context used by this engine
system - this provides the environment for controllers
Throws:
java.lang.Exception - if there is a problem on initialization

TemplateEngine

public TemplateEngine(Context context,
                      Container system,
                      java.io.File base)
               throws java.lang.Exception
Constructor for the TemplateEngine object. The instance created by this provides a mapping resource engine that loads and instantiates referenced services using the simple.http.load.MapperEngine to resolve the class names for services. Each loaded controller service is instantiated using an Environment object. The file specified acts as a local file system classpath.

Parameters:
context - this is the context used by this engine
system - the interface to the templating system used
base - this is the local file system classpath used
Throws:
java.lang.Exception - if there is a problem on initialization

TemplateEngine

public TemplateEngine(Context context,
                      Environment system,
                      java.io.File base)
               throws java.lang.Exception
Constructor for the TemplateEngine object. The instance created by this provides a mapping resource engine that loads and instantiates referenced services using the simple.http.load.MapperEngine to resolve the class names for services. Each loaded controller service is instantiated using an Environment object. The file specified acts as a local file system classpath.

Parameters:
context - this is the context used by this engine
system - the interface to the templating system used
base - this is the local file system classpath used
Throws:
java.lang.Exception - if there is a problem on initialization
Method Detail

resolve

public Resource resolve(java.lang.String target)
This will look for and retrieve the requested resource. The target given must be in the form of a request URI. This will locate the resource, using the system wide mapping scheme and return the Resource implementation that is acquired. Typically the implementation returned by this is an Action, however it can be any object that implements the Service object.

Specified by:
resolve in interface ResourceEngine
Parameters:
target - the URI style path that represents the target
Returns:
returns the Resource object refereed to