com.go.tea.runtime
Class TemplateLoader

java.lang.Object
  |
  +--com.go.tea.runtime.TemplateLoader

public class TemplateLoader
extends java.lang.Object

TemplateLoader manages the loading and execution of Tea templates. To reload templates, create a new TemplateLoader with a new ClassLoader.

Version:
15 , 9/07/00
Author:
Brian S O'Neill
See Also:
com.go.tea.util.ClassInjector

Inner Class Summary
static interface TemplateLoader.Template
          A ready-to-use Tea template.
 
Constructor Summary
TemplateLoader()
          Creates a TemplateLoader that uses the current ClassLoader as a base.
TemplateLoader(java.lang.ClassLoader baseLoader, java.lang.String packagePrefix)
          Creates a TemplateLoader that uses the given ClassLoader as a base.
TemplateLoader(java.lang.String packagePrefix)
          Creates a TemplateLoader that uses the current ClassLoader as a base.
 
Method Summary
 TemplateLoader.Template[] getLoadedTemplates()
          Returns all the templates that have been loaded thus far.
 TemplateLoader.Template getTemplate(java.lang.String name)
          Get or load a template by its full name.
protected  TemplateLoader.Template loadTemplate(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateLoader

public TemplateLoader()
Creates a TemplateLoader that uses the current ClassLoader as a base. It is recommended that templates be compiled to a base package and that a TemplateLoader be constructed with the package prefix. This way, the TemplateLoader can easily distinguish between template classes and normal classes, only loading the templates.

TemplateLoader

public TemplateLoader(java.lang.String packagePrefix)
Creates a TemplateLoader that uses the current ClassLoader as a base.
Parameters:
packagePrefix - Package that templates should be loaded from

TemplateLoader

public TemplateLoader(java.lang.ClassLoader baseLoader,
                      java.lang.String packagePrefix)
Creates a TemplateLoader that uses the given ClassLoader as a base. A base ClassLoader is used to load both template and non-template classes. The base ClassLoader can use the package prefix for determining whether or not it is loading a template.
Parameters:
baseLoader - Base ClassLoader
packagePrefix - Package that templates should be loaded from
Method Detail

getTemplate

public final TemplateLoader.Template getTemplate(java.lang.String name)
                                          throws java.lang.ClassNotFoundException,
                                                 java.lang.NoSuchMethodException,
                                                 java.lang.LinkageError
Get or load a template by its full name. The full name of a template has '.' characters to separate name parts, and it does not include a Java package prefix.
Throws:
java.lang.ClassNotFoundException - when template not found
java.lang.NoSuchMethodException - when the template is invalid

getLoadedTemplates

public final TemplateLoader.Template[] getLoadedTemplates()
Returns all the templates that have been loaded thus far.

loadTemplate

protected TemplateLoader.Template loadTemplate(java.lang.String name)
                                        throws java.lang.ClassNotFoundException,
                                               java.lang.NoSuchMethodException,
                                               java.lang.LinkageError