org.norther.tammi.spray.engine
Class DefaultContextToolFilter

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.base.DefaultContainer
          extended by org.norther.tammi.spray.filter.AbstractContainerFilter
              extended by org.norther.tammi.spray.filter.DefaultContainerFilter
                  extended by org.norther.tammi.spray.engine.DefaultContextToolFilter
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Filter, Container, Manageable, MBeanDelegate, ContextToolFilter, ContainerFilter

public class DefaultContextToolFilter
extends DefaultContainerFilter
implements ContextToolFilter

A default implementation of ContextToolFilter. The filter places tools available for templates into the context. As session context tools are saved into the session, a new session will be created if one is not available.

Based on TurbinePullService in the Apache Jakarta Turbine project.

Author:
Jason van Zyl, Sean Legassick, Ilkka Priha
See Also:
Serialized Form

Nested Class Summary
static class DefaultContextToolFilter.InternalTemplateContext
          An internal implementation of TemplateContext.
 
Field Summary
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
DefaultContextToolFilter()
          Constructs a new filter.
 
Method Summary
 void clearGlobalTools()
          Clears all global context tools.
 void clearRequestTools()
          Clears all request context tools.
 void clearSessionTools()
          Clears all session context tools.
 void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
           
 String getGlobalTool(String key)
          Gets a global context tool.
 String getRequestTool(String key)
          Gets a request context tool.
 String getSessionTool(String key)
          Gets a session context tool.
 TemplateContext getTemplateContext(ServletRequest request, ServletResponse response, FilterChain chain)
          Gets a template context loaded with context tools for the specified request.
 Set globalKeySet()
          Returns a read-only set of global keys.
 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 removeGlobalTool(String key)
          Removes a global context tool.
 void removeRequestTool(String key)
          Removes a request context tool.
 void removeSessionTool(String key)
          Removes a session context tool.
 Set requestKeySet()
          Returns a read-only set of request keys.
 Set sessionKeySet()
          Returns a read-only set of session keys.
 void setGlobalTool(String key, String tool)
          Sets a global context tool.
 void setRequestTool(String key, String tool)
          Sets a request context tool.
 void setSessionTool(String key, String tool)
          Sets a session context tool.
 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.DefaultContainerFilter
getFilter
 
Methods inherited from class org.norther.tammi.spray.filter.AbstractContainerFilter
destroy, getFilterConfig, getRequestMap, getSessionMap, init
 
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
 

Constructor Detail

DefaultContextToolFilter

public DefaultContextToolFilter()
Constructs a new filter.

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.

getRequestTool

public String getRequestTool(String key)
Description copied from interface: ContextToolFilter
Gets a request context tool.

Specified by:
getRequestTool in interface ContextToolFilter
Parameters:
key - the context key of the tool.
Returns:
the class name of the tool or null.

setRequestTool

public void setRequestTool(String key,
                           String tool)
Description copied from interface: ContextToolFilter
Sets a request context tool.

Specified by:
setRequestTool in interface ContextToolFilter
Parameters:
key - the context key of the tool.
tool - the class name of the tool.

removeRequestTool

public void removeRequestTool(String key)
Description copied from interface: ContextToolFilter
Removes a request context tool.

Specified by:
removeRequestTool in interface ContextToolFilter
Parameters:
key - the context key of the tool.

clearRequestTools

public void clearRequestTools()
Description copied from interface: ContextToolFilter
Clears all request context tools.

Specified by:
clearRequestTools in interface ContextToolFilter

requestKeySet

public Set requestKeySet()
Description copied from interface: ContextToolFilter
Returns a read-only set of request keys.

Specified by:
requestKeySet in interface ContextToolFilter
Returns:
a set of keys or an empty set.

getSessionTool

public String getSessionTool(String key)
Description copied from interface: ContextToolFilter
Gets a session context tool.

Specified by:
getSessionTool in interface ContextToolFilter
Parameters:
key - the context key of the tool.
Returns:
the class name of the tool or null.

setSessionTool

public void setSessionTool(String key,
                           String tool)
Description copied from interface: ContextToolFilter
Sets a session context tool.

Specified by:
setSessionTool in interface ContextToolFilter
Parameters:
key - the context key of the tool.
tool - the class name of the tool.

removeSessionTool

public void removeSessionTool(String key)
Description copied from interface: ContextToolFilter
Removes a session context tool.

Specified by:
removeSessionTool in interface ContextToolFilter
Parameters:
key - the context key of the tool.

clearSessionTools

public void clearSessionTools()
Description copied from interface: ContextToolFilter
Clears all session context tools.

Specified by:
clearSessionTools in interface ContextToolFilter

sessionKeySet

public Set sessionKeySet()
Description copied from interface: ContextToolFilter
Returns a read-only set of session keys.

Specified by:
sessionKeySet in interface ContextToolFilter
Returns:
a set of keys or an empty set.

getGlobalTool

public String getGlobalTool(String key)
Description copied from interface: ContextToolFilter
Gets a global context tool.

Specified by:
getGlobalTool in interface ContextToolFilter
Parameters:
key - the context key of the tool.
Returns:
the class name of the tool or null.

setGlobalTool

public void setGlobalTool(String key,
                          String tool)
Description copied from interface: ContextToolFilter
Sets a global context tool.

Specified by:
setGlobalTool in interface ContextToolFilter
Parameters:
key - the context key of the tool.
tool - the class name of the tool.

removeGlobalTool

public void removeGlobalTool(String key)
Description copied from interface: ContextToolFilter
Removes a global context tool.

Specified by:
removeGlobalTool in interface ContextToolFilter
Parameters:
key - the context key of the tool.

clearGlobalTools

public void clearGlobalTools()
Description copied from interface: ContextToolFilter
Clears all global context tools.

Specified by:
clearGlobalTools in interface ContextToolFilter

globalKeySet

public Set globalKeySet()
Description copied from interface: ContextToolFilter
Returns a read-only set of global keys.

Specified by:
globalKeySet in interface ContextToolFilter
Returns:
a set of keys or an empty set.

getTemplateContext

public TemplateContext getTemplateContext(ServletRequest request,
                                          ServletResponse response,
                                          FilterChain chain)
                                   throws TemplateException
Description copied from interface: ContextToolFilter
Gets a template context loaded with context tools for the specified request.

Specified by:
getTemplateContext in interface ContextToolFilter
Parameters:
request - the servlet request.
response - the servlet response.
chain - the filter chain.
Returns:
the loaded context.
Throws:
TemplateException - on errors.

doFilter

public void doFilter(ServletRequest request,
                     ServletResponse response,
                     FilterChain chain)
              throws ServletException,
                     IOException
Specified by:
doFilter in interface Filter
Overrides:
doFilter in class AbstractContainerFilter
Throws:
ServletException
IOException


Copyright © 2004 The Norther Organization. All rights reserved.