org.norther.tammi.spray.engine
Interface ContextToolFilter

All Superinterfaces:
Container, ContainerFilter, Filter
All Known Implementing Classes:
DefaultContextToolFilter

public interface ContextToolFilter
extends ContainerFilter

ContextToolFilter loads tools available for templates into the context. The tools are used from templates with implementation specific references. E.g. Velocity templates refer to context tools with $key, where key is the registration key of the tool. Tools may have an associated MBean registered to the context filter with their context key.

Tools implementing the ContextBindingListener interface will be notified when bound to the context or unbound from it.

Global tools are visible to all templates for all requests. The same instance of a global tool is shared by all clients and the tool must be threadsafe.

Session tools are instantiated once for each user session, and are stored into the session. Each session contains its own instance of a session tool, but as the same session can be used by several requests, the tool should be threadsafe.

Request tools are instantiated once for each request. Each request will get its own instance of a request tool and the tool needs not to be threadsafe.

Based on PullService in the Apache Jakarta Turbine project.

Author:
Jason van Zyl, Sean Legassick, Ilkka Priha

Method Summary
 void clearGlobalTools()
          Clears all global context tools.
 void clearRequestTools()
          Clears all request context tools.
 void clearSessionTools()
          Clears all session context tools.
 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 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.
 
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, doFilter, init
 

Method Detail

getRequestTool

String getRequestTool(String key)
Gets a request context tool.

Parameters:
key - the context key of the tool.
Returns:
the class name of the tool or null.

setRequestTool

void setRequestTool(String key,
                    String tool)
Sets a request context tool.

Parameters:
key - the context key of the tool.
tool - the class name of the tool.

removeRequestTool

void removeRequestTool(String key)
Removes a request context tool.

Parameters:
key - the context key of the tool.

clearRequestTools

void clearRequestTools()
Clears all request context tools.


requestKeySet

Set requestKeySet()
Returns a read-only set of request keys.

Returns:
a set of keys or an empty set.

getSessionTool

String getSessionTool(String key)
Gets a session context tool.

Parameters:
key - the context key of the tool.
Returns:
the class name of the tool or null.

setSessionTool

void setSessionTool(String key,
                    String tool)
Sets a session context tool.

Parameters:
key - the context key of the tool.
tool - the class name of the tool.

removeSessionTool

void removeSessionTool(String key)
Removes a session context tool.

Parameters:
key - the context key of the tool.

clearSessionTools

void clearSessionTools()
Clears all session context tools.


sessionKeySet

Set sessionKeySet()
Returns a read-only set of session keys.

Returns:
a set of keys or an empty set.

getGlobalTool

String getGlobalTool(String key)
Gets a global context tool.

Parameters:
key - the context key of the tool.
Returns:
the class name of the tool or null.

setGlobalTool

void setGlobalTool(String key,
                   String tool)
Sets a global context tool.

Parameters:
key - the context key of the tool.
tool - the class name of the tool.

removeGlobalTool

void removeGlobalTool(String key)
Removes a global context tool.

Parameters:
key - the context key of the tool.

clearGlobalTools

void clearGlobalTools()
Clears all global context tools.


globalKeySet

Set globalKeySet()
Returns a read-only set of global keys.

Returns:
a set of keys or an empty set.

getTemplateContext

TemplateContext getTemplateContext(ServletRequest request,
                                   ServletResponse response,
                                   FilterChain chain)
                                   throws TemplateException
Gets a template context loaded with context tools for the specified request.

Parameters:
request - the servlet request.
response - the servlet response.
chain - the filter chain.
Returns:
the loaded context.
Throws:
TemplateException - on errors.


Copyright © 2004 The Norther Organization. All rights reserved.