|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.norther.tammi.core.base.Adaptee org.norther.tammi.core.base.DefaultContainer<V> org.norther.tammi.core.security.DefaultSecureContainer<V> org.norther.tammi.spray.filter.DefaultSecureContainerFilter<V> org.norther.tammi.spray.filter.DefaultSecureContainerKeyFilter<TemplateEngine> org.norther.tammi.spray.template.DefaultPageFilter
public class DefaultPageFilter
A default implementation of PageFilter.
Based on TurbineTemplateService
in the Apache Jakarta Turbine
project.
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 |
Constructor Summary | |
---|---|
DefaultPageFilter()
Constructs a new filter. |
|
DefaultPageFilter(String key)
Constructs a new filter with a key. |
Method Summary | |
---|---|
boolean |
checkPermission(Permission permission,
ServletRequest request,
ServletResponse response,
FilterChain chain)
Checks whether or not the specified request has a permission to access a template specified in the name of the resource. |
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,
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. |
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<String,String> |
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 |
getSharedCacheName()
Gets the the shared cache of this client. |
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. |
protected CharSequence |
resolve(StringBuilder buffer,
String encoding,
boolean directly,
ServletRequest request,
ServletResponse response,
FilterChain chain,
boolean... options)
Resolves the template content either by evaluation or execution. |
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 |
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 |
setSharedCacheName(ObjectName cache)
Sets the shared cache of this client. |
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. |
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, getKey, getKeyValue, getKeyValues, isLinkedKey, setKey, setLinkedKey |
Methods inherited from class org.norther.tammi.spray.filter.DefaultSecureContainerFilter |
---|
destroy, getFilterConfig, getRequestMap, getSessionMap, init |
Methods inherited from class org.norther.tammi.core.security.DefaultSecureContainer |
---|
addAllowedPermission, addDeniedPermission, allowedPermissions, allowedRoleSet, checkPermission, clearAllowedPermissions, clearDeniedPermissions, deniedPermissions, deniedRoleSet, 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.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, init |
Field Detail |
---|
public static final String TEMPLATE_KEY
Constructor Detail |
---|
public DefaultPageFilter()
public DefaultPageFilter(String key)
key
- the filter key.Method Detail |
---|
public void postmanaged()
Manageable
postmanaged
in interface Manageable
postmanaged
in class Adaptee
public void unmanaged() throws Exception
Manageable
unmanaged
in interface Manageable
unmanaged
in class Adaptee
Exception
- if the adaptee refused to be unmanaged.public boolean isCachingDisabled()
CacheClient
isCachingDisabled
in interface CacheClient<String,String>
public void setCachingDisabled(boolean flag)
CacheClient
setCachingDisabled
in interface CacheClient<String,String>
flag
- the caching disabled flag.public void expireCached(long timestamp)
CacheClient
expireCached
in interface CacheClient<String,String>
timestamp
- the timestamp of the expiration.public void expireFraction(long timestamp, float fraction)
CacheClient
expireFraction
in interface CacheClient<String,String>
timestamp
- the timestamp of the expiration.fraction
- the fraction of entries to expire (0.0..1.0).public void clearCached()
CacheClient
clearCached
in interface CacheClient<String,String>
public ConcurrentMap<String,String> getCache(boolean... create)
CacheClient
getCache
in interface CacheClient<String,String>
create
- true to create a missing cache.
public void removeCache()
CacheClient
removeCache
in interface CacheClient<String,String>
public ObjectName getSharedCacheName()
CacheClient
getSharedCacheName
in interface CacheClient<String,String>
public void setSharedCacheName(ObjectName cache)
CacheClient
setSharedCacheName
in interface CacheClient<String,String>
cache
- the object name of the shared cache or a query.public void refresh()
Refreshable
refresh
in interface Refreshable
public long getRefreshed()
Refreshable
getRefreshed
in interface Refreshable
public String getErrorTemplate()
PageFilter
getErrorTemplate
in interface PageFilter
public void setErrorTemplate(String template)
PageFilter
setErrorTemplate
in interface PageFilter
template
- the name of the error template.public String getPageTemplate()
PageFilter
getPageTemplate
in interface PageFilter
public void setPageTemplate(String template)
PageFilter
setPageTemplate
in interface PageFilter
template
- the name of the page template.public String getDefaultBuilder()
PageFilter
getDefaultBuilder
in interface PageFilter
public void setDefaultBuilder(String name)
PageFilter
setDefaultBuilder
in interface PageFilter
name
- the name of the default builder.public String getPageTemplate(ServletRequest request, ServletResponse response, FilterChain chain)
PageFilter
getPageTemplate
in interface PageFilter
request
- the request.response
- the response.chain
- the filter chain.
public void setPageTemplate(String template, ServletRequest request, ServletResponse response, FilterChain chain)
PageFilter
setPageTemplate
in interface PageFilter
template
- the template.request
- the request.response
- the response.chain
- the filter chain.public void setPageTemplate(String template, String encoding, ServletRequest request, ServletResponse response, FilterChain chain)
PageFilter
setPageTemplate
in interface PageFilter
template
- the template.encoding
- the encoding.request
- the request.response
- the response.chain
- the filter chain.public String getPageEncoding(ServletRequest request, ServletResponse response)
PageFilter
getPageEncoding
in interface PageFilter
request
- the request.response
- the response.
public ObjectName getTaskLoaderName()
PageFilter
getTaskLoaderName
in interface PageFilter
public void setTaskLoaderName(ObjectName loader)
PageFilter
setTaskLoaderName
in interface PageFilter
loader
- the object name of the task loader or a query.public boolean isLocalContext()
TemplateExecutor
isLocalContext
in interface TemplateExecutor
public void setLocalContext(boolean flag)
TemplateExecutor
setLocalContext
in interface TemplateExecutor
flag
- true for a local context, false othrwise.public boolean isLocalizedTemplates()
TemplateExecutor
isLocalizedTemplates
in interface TemplateExecutor
public void setLocalizedTemplates(boolean flag)
TemplateExecutor
setLocalizedTemplates
in interface TemplateExecutor
flag
- the localized templates flag.public TemplateEngine getTemplateEngine(String template)
TemplateExecutor
getTemplateEngine
in interface TemplateExecutor
template
- the template.
public void execute(String template, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options) throws TemplateException
PageFilter
execute
in interface TemplateExecutor
execute
in interface PageFilter
template
- the template.request
- the request.response
- the response.chain
- the filter chain.options
- the local coxtext, localized templates and encode xml
options.
TemplateException
- if processing fails.public void execute(String template, String encoding, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options) throws TemplateException
PageFilter
execute
in interface TemplateExecutor
execute
in interface PageFilter
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.
TemplateException
- if processing fails.public void execute(CharSequence raw, String template, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options) throws TemplateException
PageFilter
execute
in interface TemplateExecutor
execute
in interface PageFilter
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.
TemplateException
- if processing fails.public CharSequence evaluate(String template, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options) throws TemplateException
PageFilter
evaluate
in interface TemplateExecutor
evaluate
in interface PageFilter
template
- the template.request
- the request.response
- the response.chain
- the filter chain.options
- the local coxtext, localized templates and encode xml
options.
TemplateException
- if processing fails.public CharSequence evaluate(String template, String encoding, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options) throws TemplateException
PageFilter
evaluate
in interface TemplateExecutor
evaluate
in interface PageFilter
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.
TemplateException
- if processing fails.public CharSequence evaluate(CharSequence raw, String template, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options) throws TemplateException
PageFilter
evaluate
in interface TemplateExecutor
evaluate
in interface PageFilter
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.
TemplateException
- if processing fails.public CharSequence resolve(String template, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options) throws TemplateException
PageFilter
resolve
in interface TemplateExecutor
resolve
in interface PageFilter
template
- the template.request
- the request.response
- the response.chain
- the filter chain.options
- the local coxtext, localized templates and encode xml
options.
TemplateException
- if processing fails.public CharSequence resolve(String template, String encoding, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options) throws TemplateException
PageFilter
resolve
in interface TemplateExecutor
resolve
in interface PageFilter
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.
TemplateException
- if processing fails.public boolean templateExists(String template, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options)
PageFilter
templateExists
in interface TemplateExecutor
templateExists
in interface PageFilter
template
- the template.request
- the request.response
- the response.chain
- the filter chain.options
- the localized templates option.
public String resolveTemplatePath(String template, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options)
PageFilter
resolveTemplatePath
in interface TemplateExecutor
resolveTemplatePath
in interface PageFilter
template
- the name of the template.request
- the template request.response
- the template response.chain
- the filter chain.options
- the localized templates option.
public boolean checkPermission(Permission permission, ServletRequest request, ServletResponse response, FilterChain chain)
checkPermission
in interface SecureFilter
checkPermission
in class DefaultSecureContainerFilter<TemplateEngine>
permission
- the permission.request
- the authenticated request.response
- the corresponding response.chain
- the active filter chain.
SecurityException
- if the access control list is invalid.public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException
The default value of the default template is 'Index'. If the default template is also unspecified, the filter does not perform any procesing.
The template extension is concluded from terminal type of the request. The template name is passed to the render method and its return value written to the response.
doFilter
in interface Filter
doFilter
in class DefaultSecureContainerFilter<TemplateEngine>
request
- the request to process.response
- the response to return.chain
- the current filter chain.
ServletException
- for servlet errors.
IOException
- for general errors.protected CharSequence resolve(StringBuilder buffer, String encoding, boolean directly, ServletRequest request, ServletResponse response, FilterChain chain, boolean... options) throws TemplateException
buffer
- the resolved template path/builder (input/output).encoding
- the encoding.directly
- the direct mode.request
- the request.response
- the response.chain
- the filter chain.options
- the local context, localized templates and encode xml
options.
TemplateException
- if processing fails.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |