org.norther.tammi.spray.template
Class DefaultPageFilter

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.base.DefaultContainer
          extended by org.norther.tammi.core.security.DefaultSecureContainer
              extended by org.norther.tammi.spray.filter.AbstractSecureContainerFilter
                  extended by org.norther.tammi.spray.filter.AbstractSecureContainerKeyFilter
                      extended by org.norther.tammi.spray.filter.DefaultSecureContainerKeyFilter
                          extended by org.norther.tammi.spray.template.DefaultPageFilter
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Filter, Container, Manageable, MBeanDelegate, Refreshable, CacheClient, AccessController, SecureContainer, TemplateExecutor, ContainerFilter, ContainerKeyFilter, KeyFilter, SecureContainerFilter, SecureContainerKeyFilter, SecureFilter, PageFilter
Direct Known Subclasses:
DefaultLayoutFilter

public class DefaultPageFilter
extends DefaultSecureContainerKeyFilter
implements PageFilter

A default implementation of PageFilter.

Based on TurbineTemplateService in the Apache Jakarta Turbine project.

Author:
John D. McNally, Dave Bryson, Jason van Zyl, Daniel Rall, Ilkka Priha
See Also:
Serialized Form

Field Summary
static String TEMPLATE_KEY
          The default key for the template.
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.spray.template.PageFilter
ANY_EXTENSION
 
Fields inherited from interface org.norther.tammi.spray.engine.TemplateExecutor
PROPERTY_ENCODING, PROPERTY_EXTENSION
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
DefaultPageFilter()
          Constructs a new filter.
DefaultPageFilter(String key)
          Constructs a new filter with a key.
 
Method Summary
 boolean checkPermission(String template, int mask, ServletRequest request, ServletResponse response, FilterChain chain)
          Checks whether or not the specified request has a permission to access the masked actions of the specified template.
 boolean checkPermission(String template, String actions, ServletRequest request, ServletResponse response, FilterChain chain)
          Checks whether or not the specified request has a permission to access the named actions of the specified template.
 void clearCached()
          Clears all cached entries without notifying.
 void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
          Activates template evaluation.
 CharSequence evaluate(CharSequence raw, String template, boolean local, ServletRequest request, ServletResponse response, FilterChain chain)
          Evaluates the named run-time content.
 CharSequence evaluate(CharSequence raw, String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Evaluates the named run-time content.
 CharSequence evaluate(String template, boolean local, boolean localized, ServletRequest request, ServletResponse response, FilterChain chain)
          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, boolean local, ServletRequest request, ServletResponse response, FilterChain chain)
          Evaluates an optionally local template by resolving its name and template engine specific extension based on terminal properties of the request.
 CharSequence evaluate(String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Evaluates the named template.
 CharSequence evaluate(String template, String encoding, boolean local, boolean localized, ServletRequest request, ServletResponse response, FilterChain chain)
          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.
 CharSequence evaluate(String template, String encoding, boolean local, ServletRequest request, ServletResponse response, FilterChain chain)
          Evaluates an optionally local template with the specified encoding by resolving its 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)
          Evaluates the named template with the specified encoding.
 void execute(CharSequence raw, String template, boolean local, ServletRequest request, ServletResponse response, FilterChain chain)
          Executes the named run-time content.
 void execute(CharSequence raw, String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Executes the named run-time content.
 void execute(String template, boolean local, boolean localized, ServletRequest request, ServletResponse response, FilterChain chain)
          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, boolean local, ServletRequest request, ServletResponse response, FilterChain chain)
          Executes an optionally local template by resolving its name and template engine specific extension based on terminal properties of the request.
 void execute(String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Executes the named template.
 void execute(String template, String encoding, boolean local, boolean localized, ServletRequest request, ServletResponse response, FilterChain chain)
          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.
 void execute(String template, String encoding, boolean local, ServletRequest request, ServletResponse response, FilterChain chain)
          Executes an optionally local template with the specified encoding by resolving its 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)
          Executes the named template with the specified encoding.
 void expireCached(long timestamp)
          Expires all cached entries notifying them about expiration.
 void expireFraction(long timestamp, float fraction)
          Expires the specified fraction of cached entries notifying them about expiration.
 ConcurrentMap getCache(boolean create)
          Gets and optionally creates the cache.
 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.
 long getRefreshed()
          Gets the last refresh timestamp.
 ObjectName getTaskLoaderName()
          Gets the the task loader of this filter.
 TemplateEngine getTemplateEngine(String template)
          Gets the referent of the template engine MBean to be applied to the specified template.
 boolean isCachingDisabled()
          Checks whether the caching is disabled.
 boolean isLocalContext()
          Gets local context flag.
 boolean isLocalizedTemplates()
          Gets the localized templates flag.
 void postmanaged()
          This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.
 void refresh()
          Refreshes the MBean.
 void removeCache()
          Removes the cache.
 CharSequence resolve(String template, boolean local, boolean localized, ServletRequest request, ServletResponse response, FilterChain chain)
          Resolves the named and optionally localized template content.
protected  CharSequence resolve(StringBuilder buffer, String encoding, boolean local, boolean localized, boolean directly, ServletRequest request, ServletResponse response, FilterChain chain)
          Resolves the template content either by evaluation or execution.
 CharSequence resolve(String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Resolves the named template content.
 CharSequence resolve(String template, String encoding, boolean local, boolean localized, ServletRequest request, ServletResponse response, FilterChain chain)
          Resolves the named and optionally localized template content with the specified encoding.
 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, boolean localized, ServletRequest request, ServletResponse response, FilterChain chain)
          Resolves an optionally localized template path for the specified request and response.
 String resolveTemplatePath(String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Resolves a template path for the specified request and response.
 void setCachingDisabled(boolean flag)
          Sets the caching disabled flag.
 void setDefaultBuilder(String name)
          Sets the default template builder.
 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.
 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, boolean localized, ServletRequest request, ServletResponse response, FilterChain chain)
          Checks whether the optionally localized template exists.
 boolean templateExists(String template, ServletRequest request, ServletResponse response, FilterChain chain)
          Checks whether the template exists.
 void unmanaged()
          This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.
 
Methods inherited from class org.norther.tammi.spray.filter.DefaultSecureContainerKeyFilter
getFilter
 
Methods inherited from class org.norther.tammi.spray.filter.AbstractSecureContainerKeyFilter
getKey, getKeyValue, getKeyValues, isLinkedKey, setKey, setLinkedKey
 
Methods inherited from class org.norther.tammi.spray.filter.AbstractSecureContainerFilter
checkPermission, destroy, getFilterConfig, getRequestMap, getSessionMap, init
 
Methods inherited from class org.norther.tammi.core.security.DefaultSecureContainer
addAllowedPermission, addDeniedPermission, allowedPermissions, allowedRoleSet, checkPermission, checkPermission, checkPermission, clearAllowedPermissions, clearDeniedPermissions, deniedPermissions, deniedRoleSet, getPermissibleRoles, getPermissibleRoles, getPermissibleRoles, isProtected, removeAllowedPermissions, removeDeniedPermissions, setAllowedPermissions, setDeniedPermissions
 
Methods inherited from class org.norther.tammi.core.base.DefaultContainer
clear, containsKey, get, getContainerKey, getContainerKey, getContainerKey, getMBean, getMBeanHandle, getMBeanHandles, getMBeanInterface, getMBeanInterface, getObjectName, getObjectNames, getQueryPattern, registryKeySet, registryKeySet, registryKeySet, registryKeySet, registryMap, registrySize, remove, setMBeanInterface, setQueryPattern, setQueryPattern
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
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 javax.servlet.Filter
destroy, init
 
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, checkPermission, checkPermission, clearAllowedPermissions, clearDeniedPermissions, deniedPermissions, deniedRoleSet, getPermissibleRoles, getPermissibleRoles, getPermissibleRoles, isProtected, removeAllowedPermissions, removeDeniedPermissions, setAllowedPermissions, setDeniedPermissions
 
Methods inherited from interface javax.servlet.Filter
destroy, init
 
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 javax.servlet.Filter
destroy, init
 
Methods inherited from interface org.norther.tammi.spray.filter.KeyFilter
getKey, getKeyValue, getKeyValues, isLinkedKey, setKey, setLinkedKey
 
Methods inherited from interface javax.servlet.Filter
destroy, init
 

Field Detail

TEMPLATE_KEY

public static final String TEMPLATE_KEY
The default key for the template.

See Also:
Constant Field Values
Constructor Detail

DefaultPageFilter

public DefaultPageFilter()
Constructs a new filter.


DefaultPageFilter

public DefaultPageFilter(String key)
Constructs a new filter with a key.

Parameters:
key - the filter key.
Method Detail

postmanaged

public void postmanaged()
Description copied from interface: Manageable
This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.

Specified by:
postmanaged in interface Manageable
Overrides:
postmanaged in class Adaptee

unmanaged

public void unmanaged()
               throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.

Specified by:
unmanaged in interface Manageable
Overrides:
unmanaged in class Adaptee
Throws:
Exception - if the adaptee refused to be unmanaged.

isCachingDisabled

public boolean isCachingDisabled()
Description copied from interface: CacheClient
Checks whether the caching is disabled.

Specified by:
isCachingDisabled in interface CacheClient
Returns:
true if the caching is disabled, true otherwise.

setCachingDisabled

public void setCachingDisabled(boolean flag)
Description copied from interface: CacheClient
Sets the caching disabled flag.

Specified by:
setCachingDisabled in interface CacheClient
Parameters:
flag - the caching disabled flag.

expireCached

public void expireCached(long timestamp)
Description copied from interface: CacheClient
Expires all cached entries notifying them about expiration.

Specified by:
expireCached in interface CacheClient
Parameters:
timestamp - the timestamp of the expiration.

expireFraction

public void expireFraction(long timestamp,
                           float fraction)
Description copied from interface: CacheClient
Expires the specified fraction of cached entries notifying them about expiration.

Specified by:
expireFraction in interface CacheClient
Parameters:
timestamp - the timestamp of the expiration.
fraction - the fraction of entries to expire (0.0..1.0).

clearCached

public void clearCached()
Description copied from interface: CacheClient
Clears all cached entries without notifying.

Specified by:
clearCached in interface CacheClient

getCache

public ConcurrentMap getCache(boolean create)
Description copied from interface: CacheClient
Gets and optionally creates the cache.

Specified by:
getCache in interface CacheClient
Parameters:
create - true to create a missing cache.
Returns:
the cache or null if disabled.

removeCache

public void removeCache()
Description copied from interface: CacheClient
Removes the cache.

Specified by:
removeCache in interface CacheClient

refresh

public void refresh()
Description copied from interface: Refreshable
Refreshes the MBean.

Specified by:
refresh in interface Refreshable

getRefreshed

public long getRefreshed()
Description copied from interface: Refreshable
Gets the last refresh timestamp.

Specified by:
getRefreshed in interface Refreshable
Returns:
the timestamp of the last refresh.

getErrorTemplate

public String getErrorTemplate()
Description copied from interface: TemplateExecutor
Gets the error template.

Specified by:
getErrorTemplate in interface TemplateExecutor
Returns:
the name of the error template.

setErrorTemplate

public void setErrorTemplate(String template)
Description copied from interface: TemplateExecutor
Sets the error template. The error template will be evaluated if the evaluation of the target template fails.

Specified by:
setErrorTemplate in interface TemplateExecutor
Parameters:
template - the name of the error template.

getPageTemplate

public String getPageTemplate()
Description copied from interface: PageFilter
Gets the default page template.

Specified by:
getPageTemplate in interface PageFilter
Returns:
the name of the default page template.

setPageTemplate

public void setPageTemplate(String template)
Description copied from interface: PageFilter
Sets the default page template. The page template will be evaluated if the request doesn't contain any target template information.

Specified by:
setPageTemplate in interface PageFilter
Parameters:
template - the name of the page template.

getDefaultBuilder

public String getDefaultBuilder()
Description copied from interface: PageFilter
Gets the default template builder.

Specified by:
getDefaultBuilder in interface PageFilter
Returns:
the name of the default builder.

setDefaultBuilder

public void setDefaultBuilder(String name)
Description copied from interface: PageFilter
Sets the default template builder.

Specified by:
setDefaultBuilder in interface PageFilter
Parameters:
name - the name of the default builder.

getPageTemplate

public String getPageTemplate(ServletRequest request,
                              ServletResponse response,
                              FilterChain chain)
Description copied from interface: PageFilter
Gets the current page template of the specified request.

Specified by:
getPageTemplate in interface PageFilter
Parameters:
request - the request.
response - the response.
chain - the filter chain.
Returns:
the template or null.

setPageTemplate

public void setPageTemplate(String template,
                            ServletRequest request,
                            ServletResponse response,
                            FilterChain chain)
Description copied from interface: PageFilter
Sets the current page template of the specified request.

Specified by:
setPageTemplate in interface PageFilter
Parameters:
template - the template.
request - the request.
response - the response.
chain - the filter chain.

setPageTemplate

public void setPageTemplate(String template,
                            String encoding,
                            ServletRequest request,
                            ServletResponse response,
                            FilterChain chain)
Description copied from interface: PageFilter
Sets the current page template of the specified request with encoding.

Specified by:
setPageTemplate in interface PageFilter
Parameters:
template - the template.
encoding - the encoding.
request - the request.
response - the response.
chain - the filter chain.

getPageEncoding

public String getPageEncoding(ServletRequest request,
                              ServletResponse response)
Description copied from interface: PageFilter
Gets the current page encoding of the specified request.

Specified by:
getPageEncoding in interface PageFilter
Parameters:
request - the request.
response - the response.
Returns:
the encoding.

getTaskLoaderName

public ObjectName getTaskLoaderName()
Description copied from interface: PageFilter
Gets the the task loader of this filter.

Specified by:
getTask