org.norther.tammi.spray.engine
Interface TemplateExecutor

All Known Subinterfaces:
LayoutFilter, PageFilter
All Known Implementing Classes:
DefaultLayoutFilter, DefaultPageFilter

public interface TemplateExecutor

An interface to template executors executing and evaluating templates in different markup languages applying configured template engines.

Author:
Ilkka Priha

Field Summary
static String PROPERTY_ENCODING
          A template encoding for properties used as templates.
static String PROPERTY_EXTENSION
          An extension for properties used as templates.
 
Method Summary
 CharSequence evaluate(CharSequence raw, String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Evaluates the named run-time content.
 CharSequence evaluate(String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Evaluates the named template.
 CharSequence evaluate(String template, String encoding, ServletRequest request, ServletResponse response, FilterChain chain)
          Evaluates the named template with the specified encoding.
 void execute(CharSequence raw, String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Executes the named run-time content.
 void execute(String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Executes the named template.
 void execute(String template, String encoding, ServletRequest request, ServletResponse response, FilterChain chain)
          Executes the named template with the specified encoding.
 String getErrorTemplate()
          Gets the error template.
 TemplateEngine getTemplateEngine(String template)
          Gets the referent of the template engine MBean to be applied to the specified template.
 boolean isLocalContext()
          Gets local context flag.
 boolean isLocalizedTemplates()
          Gets the localized templates flag.
 CharSequence resolve(String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Resolves the named template content.
 CharSequence resolve(String template, String encoding, ServletRequest request, ServletResponse response, FilterChain chain)
          Resolves the named template content with the specified encoding.
 String resolveTemplatePath(String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Resolves a template path for the specified request and response.
 void setErrorTemplate(String template)
          Sets the error template.
 void setLocalContext(boolean flag)
          Sets the local context flag.
 void setLocalizedTemplates(boolean flag)
          Sets the localized templates flag.
 boolean templateExists(String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Checks whether the template exists.
 

Field Detail

PROPERTY_EXTENSION

static final String PROPERTY_EXTENSION
An extension for properties used as templates.

See Also:
Constant Field Values

PROPERTY_ENCODING

static final String PROPERTY_ENCODING
A template encoding for properties used as templates.

See Also:
Constant Field Values
Method Detail

isLocalContext

boolean isLocalContext()
Gets local context flag.

Returns:
true for a local context, false othrwise.

setLocalContext

void setLocalContext(boolean flag)
Sets the local context flag. Local context is created for the rendered template to prevent local changes to interfere with the global context.

Parameters:
flag - true for a local context, false othrwise.

isLocalizedTemplates

boolean isLocalizedTemplates()
Gets the localized templates flag.

Returns:
the localized templates flag.

setLocalizedTemplates

void setLocalizedTemplates(boolean flag)
Sets the localized templates flag. Localized template names are formed by inserting the locale string between the plain template name and the template extension.

Parameters:
flag - the localized templates flag.

getErrorTemplate

String getErrorTemplate()
Gets the error template.

Returns:
the name of the error template.

setErrorTemplate

void setErrorTemplate(String template)
Sets the error template. The error template will be evaluated if the evaluation of the target template fails.

Parameters:
template - the name of the error template.

getTemplateEngine

TemplateEngine getTemplateEngine(String template)
Gets the referent of the template engine MBean to be applied to the specified template.

Parameters:
template - the template.
Returns:
the template engine.
Throws:
IllegalStateException - if not available.

execute

void execute(String template,
             ServletRequest request,
             ServletResponse response,
             FilterChain chain)
             throws TemplateException
Executes the named template. Absolute template paths point to the template executor root. Relative paths are relative to the current template path.

Parameters:
template - the template.
request - the request.
response - the response.
chain - the filter chain.
Throws:
TemplateException - if processing fails.

execute

void execute(String template,
             String encoding,
             ServletRequest request,
             ServletResponse response,
             FilterChain chain)
             throws TemplateException
Executes the named template with the specified encoding. Absolute template paths point to the template executor root. Relative paths are relative to the current template path.

Parameters:
template - the template.
encoding - the encoding.
request - the request.
response - the response.
chain - the filter chain.
Throws:
TemplateException - if processing fails.

execute

void execute(CharSequence raw,
             String template,
             ServletRequest request,
             ServletResponse response,
             FilterChain chain)
             throws TemplateException
Executes the named run-time content.

Parameters:
raw - the content.
template - a virtual template for identifying the content.
request - the request.
response - the response.
chain - the filter chain.
Throws:
TemplateException - if processing fails.

evaluate

CharSequence evaluate(String template,
                      ServletRequest request,
                      ServletResponse response,
                      FilterChain chain)
                      throws TemplateException
Evaluates the named template. Absolute template paths point to the template executor root. Relative paths are relative to the current template path.

Parameters:
template - the template.
request - the request.
response - the response.
chain - the filter chain.
Returns:
the evaluated content.
Throws:
TemplateException - if processing fails.

evaluate

CharSequence evaluate(String template,
                      String encoding,
                      ServletRequest request,
                      ServletResponse response,
                      FilterChain chain)
                      throws TemplateException
Evaluates the named template with the specified encoding. Absolute template paths point to the template executor root. Relative paths are relative to the current template path.

Parameters:
template - the template.
encoding - the encoding.
request - the request.
response - the response.
chain - the filter chain.
Returns:
the evaluated content.
Throws:
TemplateException - if processing fails.

evaluate

CharSequence evaluate(CharSequence raw,
                      String template,
                      ServletRequest request,
                      ServletResponse response,
                      FilterChain chain)
                      throws TemplateException
Evaluates the named run-time content.

Parameters:
raw - the content.
template - a virtual template for identifying the content.
request - the request.
response - the response.
chain - the filter chain.
Returns:
the evaluated content.
Throws:
TemplateException - if processing fails.

resolve

CharSequence resolve(String template,
                     ServletRequest request,
                     ServletResponse response,
                     FilterChain chain)
                     throws TemplateException
Resolves the named template content. The exact result depends on the implementation allowing different template path resolving, localization and layouting mechanisms.

Parameters:
template - the template.
request - the request.
response - the response.
chain - the filter chain.
Returns:
the resolved content.
Throws:
TemplateException - if processing fails.

resolve

CharSequence resolve(String template,
                     String encoding,
                     ServletRequest request,
                     ServletResponse response,
                     FilterChain chain)
                     throws TemplateException
Resolves the named template content with the specified encoding. The exact result depends on the implementation allowing different template path resolving, localization and layouting mechanisms.

Parameters:
template - the template.
encoding - the encoding.
request - the request.
response - the response.
chain - the filter chain.
Returns:
the resolved content.
Throws:
TemplateException - if processing fails.

templateExists

boolean templateExists(String template,
                       ServletRequest request,
                       ServletResponse response,
                       FilterChain chain)
Checks whether the template exists. Absolute template paths point to the template executor root. Relative paths are relative to the current template path.

Parameters:
template - the template.
request - the request.
response - the response.
chain - the filter chain.
Returns:
true if the template exists, otherwise false.

resolveTemplatePath

String resolveTemplatePath(String template,
                           ServletRequest request,
                           ServletResponse response,
                           FilterChain chain)
Resolves a template path for the specified request and response. Absolute template paths point to the template executor root. Relative paths are relative to the current template path.

Parameters:
template - the name of the template.
request - the template request.
response - the template response.
chain - the filter chain.
Returns:
the template path or null.


Copyright © 2004 The Norther Organization. All rights reserved.