org.norther.tammi.spray.template
Interface PageFilter

All Superinterfaces:
AccessController, CacheClient<String,String>, Container<TemplateEngine>, ContainerFilter<TemplateEngine>, ContainerKeyFilter<TemplateEngine>, Filter, KeyFilter, Refreshable, SecureContainerFilter<TemplateEngine>, SecureContainerKeyFilter<TemplateEngine>, SecureFilter, TemplateExecutor
All Known Subinterfaces:
LayoutFilter
All Known Implementing Classes:
DefaultLayoutFilter, DefaultPageFilter

public interface PageFilter
extends TemplateExecutor, SecureContainerKeyFilter<TemplateEngine>, CacheClient<String,String>

PageFilter executes and evaluates templates specified in URL parameters of the request. The filter key of the filter is applied to request parameters to find the name of the template. If the key doesn't specify a template, the path info is applied. If the path info fails, the default template is processed.

The template may have a builder, which is executed before redering the template. The plain class name of the builder can be the same as the plain name of the template. Alternatively, a qualified default builder may have a package name corresponding to any part of the template path and the most specific one is applied. The builder must implement the Task interface and be located in one of the defined packages of TaskLoader.

Templates can be protected with an access controller. Read permission is required. Permissions for a template are granted using its name as a resource. Access rights are checked only for the page template, not for separately processed sub-templates.

Based on TemplateService in the Apache Jakarta Turbine project.

Version:
$Id: PageFilter.java,v 1.42 2009-09-28 15:08:27 cvsimp Exp $
Author:
John D. McNally, Jason van Zyl, Daniel Rall, Ilkka Priha

Field Summary
static String ANY_EXTENSION
          The wildcard.
 
Fields inherited from interface org.norther.tammi.spray.engine.TemplateExecutor
PROPERTY_ENCODING, PROPERTY_EXTENSION
 
Method Summary
 CharSequence evaluate(CharSequence raw, String template, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options)
          Evaluates the named run-time content.
 CharSequence evaluate(String template, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options)
          Evaluates an optionally local template by resolving its optionally localized name and template engine specific extension based on terminal properties of the request.
 CharSequence evaluate(String template, String encoding, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options)
          Evaluates an optionally local template with the specified encoding by resolving its optionally localized name and template engine specific extension based on terminal properties of the request.
 void execute(CharSequence raw, String template, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options)
          Executes the named run-time content.
 void execute(String template, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options)
          Executes an optionally local template by resolving its optionally localized name and template engine specific extension based on terminal properties of the request.
 void execute(String template, String encoding, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options)
          Executes an optionally local template with the specified encoding by resolving its optionally localized name and template engine specific extension based on terminal properties of the request.
 String getDefaultBuilder()
          Gets the default template builder.
 String getErrorTemplate()
          Gets the error template.
 String getPageEncoding(ServletRequest request, ServletResponse response)
          Gets the current page encoding of the specified request.
 String getPageTemplate()
          Gets the default page template.
 String getPageTemplate(ServletRequest request, ServletResponse response, FilterChain chain)
          Gets the current page template of the specified request.
 ObjectName getTaskLoaderName()
          Gets the the task loader of this filter.
 CharSequence resolve(String template, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options)
          Resolves the named and optionally localized template content.
 CharSequence resolve(String template, String encoding, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options)
          Resolves the named and optionally localized template content with the specified encoding.
 String resolveTemplatePath(String template, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options)
          Resolves an optionally localized template path for the specified request and response.
 void setDefaultBuilder(String name)
          Sets the default template builder.
 void setErrorTemplate(String template)
          Sets the error template.
 void setPageTemplate(String template)
          Sets the default page template.
 void setPageTemplate(String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Sets the current page template of the specified request.
 void setPageTemplate(String template, String encoding, ServletRequest request, ServletResponse response, FilterChain chain)
          Sets the current page template of the specified request with encoding.
 void setTaskLoaderName(ObjectName loader)
          Sets the task loader of this filter.
 boolean templateExists(String template, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options)
          Checks whether the optionally localized template exists.
 
Methods inherited from interface org.norther.tammi.spray.engine.TemplateExecutor
getTemplateEngine, isLocalContext, isLocalizedTemplates, setLocalContext, setLocalizedTemplates
 
Methods inherited from interface org.norther.tammi.spray.filter.SecureFilter
checkPermission
 
Methods inherited from interface org.norther.tammi.core.security.AccessController
addAllowedPermission, addDeniedPermission, allowedPermissions, allowedRoleSet, checkPermission, clearAllowedPermissions, clearDeniedPermissions, deniedPermissions, deniedRoleSet, getPermissibleRoles, isProtected, removeAllowedPermissions, removeDeniedPermissions, setAllowedPermissions, setDeniedPermissions
 
Methods inherited from interface org.norther.tammi.core.base.Container
clear, containsKey, get, getContainerKey, getContainerKey, getContainerKey, getMBean, getMBeanInterface, getMBeanInterface, getObjectName, getObjectNames, getQueryPattern, registryKeySet, registryKeySet, registryKeySet, registryKeySet, registryMap, registrySize, remove, setMBeanInterface, setQueryPattern, setQueryPattern
 
Methods inherited from interface org.norther.tammi.spray.filter.KeyFilter
getKey, getKeyValue, getKeyValues, isLinkedKey, setKey, setLinkedKey
 
Methods inherited from interface javax.servlet.Filter
destroy, doFilter, init
 
Methods inherited from interface org.norther.tammi.core.cache.CacheClient
clearCached, expireCached, expireFraction, getCache, getSharedCacheName, isCachingDisabled, removeCache, setCachingDisabled, setSharedCacheName
 
Methods inherited from interface org.norther.tammi.core.base.Refreshable
getRefreshed, refresh
 

Field Detail

ANY_EXTENSION

static final String ANY_EXTENSION
The wildcard.

See Also:
Constant Field Values
Method Detail

getPageTemplate

String getPageTemplate()
Gets the default page template.

Returns:
the name of the default page template.

setPageTemplate

void setPageTemplate(String template)
Sets the default page template. The page template will be evaluated if the request doesn't contain any target template information.

Parameters:
template - the name of the page template.

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.

getDefaultBuilder

String getDefaultBuilder()
Gets the default template builder.

Returns:
the name of the default builder.

setDefaultBuilder

void setDefaultBuilder(String name)
Sets the default template builder.

Parameters:
name - the name of the default builder.

getPageTemplate

String getPageTemplate(ServletRequest request,
                       ServletResponse response,
                       FilterChain chain)
Gets the current page template of the specified request.

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

setPageTemplate

void setPageTemplate(String template,
                     ServletRequest request,
                     ServletResponse response,
                     FilterChain chain)
Sets the current page template of the specified request.

Parameters:
template - the template.
request - the request.
response - the response.
chain - the filter chain.

setPageTemplate

void setPageTemplate(String template,
                     String encoding,
                     ServletRequest request,
                     ServletResponse response,
                     FilterChain chain)
Sets the current page template of the specified request with encoding.

Parameters:
template - the template.
encoding - the encoding.
request - the request.
response - the response.
chain - the filter chain.

getPageEncoding

String getPageEncoding(ServletRequest request,
                       ServletResponse response)
Gets the current page encoding of the specified request.

Parameters:
request - the request.
response - the response.
Returns:
the encoding.

getTaskLoaderName

ObjectName getTaskLoaderName()
Gets the the task loader of this filter.

Returns:
the object name of the task loader or a query.

setTaskLoaderName

void setTaskLoaderName(ObjectName loader)
Sets the task loader of this filter. If it is not set, the default one will be used.

Parameters:
loader - the object name of the task loader or a query.

execute

void execute(String template,
             ServletRequest request,
             ServletResponse response,
             FilterChain chain,
             boolean... options)
             throws TemplateException
Executes an optionally local template by resolving its optionally localized name and template engine specific extension based on terminal properties of the request. Absolute template paths point to the template engine root. Relative paths are relative to the current page template path.

Specified by:
execute in interface TemplateExecutor
Parameters:
template - the template.
request - the request.
response - the response.
chain - the filter chain.
options - the local coxtext, localized templates and encode xml options.
Throws:
TemplateException - if processing fails.

execute

void execute(String template,
             String encoding,
             ServletRequest request,
             ServletResponse response,
             FilterChain chain,
             boolean... options)
             throws TemplateException
Executes an optionally local template with the specified encoding by resolving its optionally localized name and template engine specific extension based on terminal properties of the request. Absolute template paths point to the template engine root. Relative paths are relative to the current page template path.

Specified by:
execute in interface TemplateExecutor
Parameters:
template - the template.
encoding - the encoding.
request - the request.
response - the response.
chain - the filter chain.
options - the local coxtext, localized templates and encode xml options.
Throws:
TemplateException - if processing fails.

execute

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

Specified by:
execute in interface TemplateExecutor
Parameters:
raw - the content.
template - a virtual template for identifying the content.
request - the request.
response - the response.
chain - the filter chain.
options - the local coxtext and encode xml options.
Throws:
TemplateException - if processing fails.

evaluate

CharSequence evaluate(String template,
                      ServletRequest request,
                      ServletResponse response,
                      FilterChain chain,
                      boolean... options)
                      throws TemplateException
Evaluates an optionally local template by resolving its optionally localized name and template engine specific extension based on terminal properties of the request. Absolute template paths point to the template engine root. Relative paths are relative to the current page template path.

Specified by:
evaluate in interface TemplateExecutor
Parameters:
template - the template.
request - the request.
response - the response.
chain - the filter chain.
options - the local coxtext, localized templates and encode xml options.
Returns:
the built content.
Throws:
TemplateException - if processing fails.

evaluate

CharSequence evaluate(String template,
                      String encoding,
                      ServletRequest request,
                      ServletResponse response,
                      FilterChain chain,
                      boolean... options)
                      throws TemplateException
Evaluates an optionally local template with the specified encoding by resolving its optionally localized name and template engine specific extension based on terminal properties of the request. Absolute template paths point to the template engine root. Relative paths are relative to the current page template path.

Specified by:
evaluate in interface TemplateExecutor
Parameters:
template - the template.
encoding - the encoding.
request - the request.
response - the response.
chain - the filter chain.
options - the local coxtext, localized templates and encode xml options.
Returns:
the built content.
Throws:
TemplateException - if processing fails.

evaluate

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

Specified by:
evaluate in interface TemplateExecutor
Parameters:
raw - the content.
template - a virtual template for identifying the content.
request - the request.
response - the response.
chain - the filter chain.
options - the local coxtext and encode xml options.
Returns:
the evaluated content.
Throws:
TemplateException - if processing fails.

resolve

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

Specified by:
resolve in interface TemplateExecutor
Parameters:
template - the template.
request - the request.
response - the response.
chain - the filter chain.
options - the local coxtext, localized templates and encode xml options.
Returns:
the resolved content.
Throws:
TemplateException - if processing fails.

resolve

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

Specified by:
resolve in interface TemplateExecutor
Parameters:
template - the template.
encoding - the encoding.
request - the request.
response - the response.
chain - the filter chain.
options - the local coxtext, localized templates and encode xml options.
Returns:
the resolved content.
Throws:
TemplateException - if processing fails.

templateExists

boolean templateExists(String template,
                       ServletRequest request,
                       ServletResponse response,
                       FilterChain chain,
                       boolean... options)
Checks whether the optionally localized template exists. The template name is resolved in the same way as in execute and evaluate methods. Absolute template paths point to the template engine root. Relative paths are relative to the current page template path.

Specified by:
templateExists in interface TemplateExecutor
Parameters:
template - the template.
request - the request.
response - the response.
chain - the filter chain.
options - the localized templates option.
Returns:
true if the template exists, otherwise false.

resolveTemplatePath

String resolveTemplatePath(String template,
                           ServletRequest request,
                           ServletResponse response,
                           FilterChain chain,
                           boolean... options)
Resolves an optionally localized 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.

Specified by:
resolveTemplatePath in interface TemplateExecutor
Parameters:
template - the name of the template.
request - the template request.
response - the template response.
chain - the filter chain.
options - the localized templates option.
Returns:
the template path or null.


Copyright © 2004 The Norther Organization. All rights reserved.