Class GroovyServerTemplate

  extended by sunlabs.brazil.template.Template
      extended by sunlabs.brazil.groovy.GroovyServerTemplate (view source)
All Implemented Interfaces:

public class GroovyServerTemplate
extends Template

The GroovyServerTemplate looks for each <groovy> tag in an HTML page and treats the following data up to the next </groovy>) tag as a groovy script to evaluate.

All Groovy fragments within a given page are evaluated in the same Groovy interpreter. The Groovy interpreter actually lives for the entire duration of this Template object, so the user can implement persistence across requests: Each session gets its own interpreter.

The following configuration parameters are used to initialize this template.

The name of the Groovy script to evaluate when the interpreter is created. This script only evaluated when the interp is created, not on every request. The variables prefix and server are set before this file is evaluated, and are references to the parameters passed to a handler init method.
The document root, if the script is a relative file name. If the "root" property under the template prefix is not found, the global "root" property is used. If the global "root" property is not found, the current directory is used.
If this configuration parameter is present, this class replaces the <groovy> and </groovy> tags with comments, so the user can keep track of where the dynamically generated content is coming from by examining the comments in the resultant HTML document. By default, the <groovy> and </groovy> are completely eliminated from the HTML document rather than changed into comments.

Before evaluating each HTML document, this class sets variables in the Groovy interpreter, which can be used to interact back with Java to do things like set the response headers:

Exposes the Request Java object. It is set anew at each request.
Exposes the handler prefix String.
Exposes the handler Server object.

Field Summary
Fields inherited from class sunlabs.brazil.template.Template
Constructor Summary
Method Summary
 boolean init(RewriteContext hr)
          Initialize the groovy interperter (1st time only) and set the current request object.
 void tag_groovy(RewriteContext hr)
Methods inherited from class sunlabs.brazil.template.Template
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public GroovyServerTemplate()
Method Detail


public boolean init(RewriteContext hr)
Initialize the groovy interperter (1st time only) and set the current request object.

Specified by:
init in interface TemplateInterface
init in class Template


public void tag_groovy(RewriteContext hr)

Version Kenai-svn-r24, Generated 08/18/09
Copyright (c) 2001-2009, Sun Microsystems.