sunlabs.brazil.template

Class Template

public class Template extends Object implements TemplateInterface

Parent for all classes that are templates. This class is used primarily as a sanity check, to make sure only classes that intend to be used as templates actually are. Subclasses are expected to implement methods whose names corrospond to html/XML tags that are discovered and called via introspection.

In the future, various "dummy" subclasses may be used as alternate parents to indicate which session behavior is expected.

In the current implementation, access to each instance is restricted to one thread at a time. In many situations this is a good compromise between ease of coding templates and server performance. As a new instance is created for each session, multiple threads may be active at once, although only one per session.

In the future, it is expected that an alternative mode of running templates will be available that will remove the current synchonization lock around each template instance, allowing multiple threads to access each instance at once.

To take advantage of this new scheme templates should be written thread safe. They should avoid using instance variables if possible. If state needs to be passed among methods, it may be stored in the RewriteContext, as each thread has its own.

Configuration properties:

debug
If this configuration parameter is true, sub-classes that call the debug method will have diagnostic information added to the html output as comments. If no debug property is associated with the template prefix, the value of debug with the prefix for the class registering this template is used instead.

Author: Stephen Uhler

UNKNOWN: %W

Field Summary
booleandebug
Method Summary
protected voiddebug(RewriteContext hr, String msg)
Add a diagnostic comment to html output, if "debug" is set in the request properties.
protected voiddebug(RewriteContext hr)
Add current tag as a comment to the html
booleandone(RewriteContext hr)
Called after all tags have been processed, one final chance.
booleaninit(RewriteContext hr)
Called before this template processes any tags.

Field Detail

debug

public transient boolean debug

Method Detail

debug

protected void debug(RewriteContext hr, String msg)
Add a diagnostic comment to html output, if "debug" is set in the request properties. The comment may be modified to prevent nested comments.

Parameters: msg The message to include as a comment

debug

protected void debug(RewriteContext hr)
Add current tag as a comment to the html

done

public boolean done(RewriteContext hr)
Called after all tags have been processed, one final chance.

init

public boolean init(RewriteContext hr)
Called before this template processes any tags.