org.norther.tammi.spray.engine.tool
Class ChainTool

java.lang.Object
  extended by org.norther.tammi.core.pool.RecyclableSupport
      extended by org.norther.tammi.core.pool.PoolableSupport
          extended by org.norther.tammi.spray.engine.tool.GlobalTool
              extended by org.norther.tammi.spray.engine.tool.ContextTool
                  extended by org.norther.tammi.spray.engine.tool.ChainTool
All Implemented Interfaces:
Serializable, Cloneable, EventListener, FilterChain, Poolable, Recyclable, ContextBindingListener, HttpFilterChain

public class ChainTool
extends ContextTool
implements HttpFilterChain

A request context tool for filter chaining.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
ChainTool()
          Constructs a new chain.
 
Method Summary
 void bindToRequest(ObjectName name)
          Binds an MBean to the current request.
 void bindToSession(ObjectName name)
          Binds an MBean to the current session.
 void clearErrors()
          Clears throwables from the error stack of this chain.
 void closeResponse()
          Closes the current response after committing.
 boolean containsErrors()
          Checks whether this chain contains errors.
 void doFilter(ServletRequest request, ServletResponse response)
          Passes the request and response to the next filter.
 void doFilter(ServletRequest request, ServletResponse response, Filter filter)
          Invokes the specified filter.
 void doFilter(ServletRequest request, ServletResponse response, FilterMBeanReference[] filters)
          Invokes the first filter in a list of filter handles and continues with the rest as long as the preceding filter passes the request forward.
 ConnectorExtension getConnector()
          Gets the connector extension.
 Filter getCurrentFilter()
          Gets the current filter of this chain.
 Pipe getCurrentPipe()
          Gets the current pipe of this chain.
 Throwable getError()
          Gets the last throwable from the error stack of this chain.
 List getErrors()
          Gets a list of all throwables in the error stack of this chain.
 Locale getLocale()
          Gets the current locale.
 MBeanServer getMBeanServer()
          Gets the current MBean server if available.
 Filter getNearestFilter(Class clazz)
          Gets the nearest registered filter of the specified class from the filter stack of this chain.
 Filter getNextFilter(Class clazz)
          Gets the next registered filter of the specified class in the current pipe to be activated after the current one.
 String getParameter(String name)
          Gets the named request parameter.
 String getParameter(String name, String def)
          Gets a named request parameter with a default value.
 Map getParameterMap()
          Gets the request parameter map.
 String[] getParameters(String name)
          Gets the named request parameters.
 Filter getPreviousFilter(Class clazz)
          Gets the previous registered filter of the specified class activated before the current one from the filter stack of this chain.
 List getPreviousFilters()
          Gets a list of all filters activated before the current one from the filter stack of this chain.
 ProtocolExtension getProtocol()
          Gets the protocol extension.
 ServletRequest getRequest()
          Gets the current request if available.
 ServletResponse getResponse()
          Gets the current response if available.
 HttpSession getSession()
          Gets or creates the current session.
 TerminalExtension getTerminal()
          Gets the terminal extension.
 boolean isInvalidatedSession()
          Checks whether the the active session is invalidated.
 Throwable popError()
          Pops a throwable from the error stack.
 void pushError(Throwable error)
          Pushes a throwable to the error stack without throwing one.
 void releaseFromRequest(ObjectName name)
          Releases an MBean from the current request without unregistering.
 void releaseFromSession(ObjectName name)
          Releases an MBean from the current session without unregistering.
 void setInvalidatedSession(boolean flag)
          Sets whether the the active session is invalidated.
 void terminate()
          Terminates the filter chain.
 
Methods inherited from class org.norther.tammi.spray.engine.tool.ContextTool
dispose, getFilter, getFilterChain, getFilterKey, getPrincipal, isFilterChanged
 
Methods inherited from class org.norther.tammi.spray.engine.tool.GlobalTool
clone, getContext, getContextToolFilter, getName, isBound, nop, toString, valueBound, valueUnbound
 
Methods inherited from class org.norther.tammi.core.pool.PoolableSupport
disposed, recycled
 
Methods inherited from class org.norther.tammi.core.pool.RecyclableSupport
isDisposed, recycle
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.core.pool.Recyclable
isDisposed, recycle
 

Constructor Detail

ChainTool

public ChainTool()
Constructs a new chain.

Method Detail

getRequest

public ServletRequest getRequest()
Description copied from class: ContextTool
Gets the current request if available.

Specified by:
getRequest in interface HttpFilterChain
Overrides:
getRequest in class ContextTool
Returns:
the request or null.

getResponse

public ServletResponse getResponse()
Description copied from class: ContextTool
Gets the current response if available.

Specified by:
getResponse in interface HttpFilterChain
Overrides:
getResponse in class ContextTool
Returns:
the response or null.

isInvalidatedSession

public boolean isInvalidatedSession()
Description copied from interface: HttpFilterChain
Checks whether the the active session is invalidated.

Specified by:
isInvalidatedSession in interface HttpFilterChain
Returns:
true if invalidated, false otherwise.

setInvalidatedSession

public void setInvalidatedSession(boolean flag)
Description copied from interface: HttpFilterChain
Sets whether the the active session is invalidated.

Specified by:
setInvalidatedSession in interface HttpFilterChain
Parameters:
flag - true if invalidated, false otherwise.

getCurrentPipe

public Pipe getCurrentPipe()
Description copied from interface: HttpFilterChain
Gets the current pipe of this chain.

Specified by:
getCurrentPipe in interface HttpFilterChain
Returns:
the current pipe or null.

getCurrentFilter

public Filter getCurrentFilter()
Description copied from interface: HttpFilterChain
Gets the current filter of this chain.

Specified by:
getCurrentFilter in interface HttpFilterChain
Returns:
the current filter or null.

getNearestFilter

public Filter getNearestFilter(Class clazz)
Description copied from interface: HttpFilterChain
Gets the nearest registered filter of the specified class from the filter stack of this chain. The non-activated filters in the current pipe are included in the search if the filter is not in the filter stack.

Specified by:
getNearestFilter in interface HttpFilterChain
Parameters:
clazz - the class or interface of the filter or null for any.
Returns:
the nearest filter or null.

getPreviousFilter

public Filter getPreviousFilter(Class clazz)
Description copied from interface: HttpFilterChain
Gets the previous registered filter of the specified class activated before the current one from the filter stack of this chain. The current filter is included in the search.

Specified by:
getPreviousFilter in interface HttpFilterChain
Parameters:
clazz - the class or interface of the filter or null for any.
Returns:
the previous filter or null.

getPreviousFilters

public List getPreviousFilters()
Description copied from interface: HttpFilterChain
Gets a list of all filters activated before the current one from the filter stack of this chain. The current filter is included in the list.

Specified by:
getPreviousFilters in interface HttpFilterChain
Returns:
an unmodiafiable list of activated filters.

getNextFilter

public Filter getNextFilter(Class clazz)
Description copied from interface: HttpFilterChain
Gets the next registered filter of the specified class in the current pipe to be activated after the current one. The current filter is not included in the search.

Specified by:
getNextFilter in interface HttpFilterChain
Parameters:
clazz - the class or interface of the filter or null for any.
Returns:
the next filter or null.

getMBeanServer

public MBeanServer getMBeanServer()
Description copied from class: GlobalTool
Gets the current MBean server if available.

Specified by:
getMBeanServer in interface HttpFilterChain
Overrides:
getMBeanServer in class GlobalTool
Returns:
the MBean server or null.

getError

public Throwable getError()
Description copied from interface: HttpFilterChain
Gets the last throwable from the error stack of this chain.

Specified by:
getError in interface HttpFilterChain
Returns:
the throwable or null.

getErrors

public List getErrors()
Description copied from interface: HttpFilterChain
Gets a list of all throwables in the error stack of this chain.

Specified by:
getErrors in interface HttpFilterChain
Returns:
an unmodifiable list of throwables.

pushError

public void pushError(Throwable error)
Description copied from interface: HttpFilterChain
Pushes a throwable to the error stack without throwing one.

Specified by:
pushError in interface HttpFilterChain
Parameters:
error - the reason throwable.

popError

public Throwable popError()
Description copied from interface: HttpFilterChain
Pops a throwable from the error stack.

Specified by:
popError in interface HttpFilterChain
Returns:
the thowable or null.

containsErrors

public boolean containsErrors()
Description copied from interface: HttpFilterChain
Checks whether this chain contains errors.

Specified by:
containsErrors in interface HttpFilterChain
Returns:
true if the error stack is not empty.

clearErrors

public void clearErrors()
Description copied from interface: HttpFilterChain
Clears throwables from the error stack of this chain.

Specified by:
clearErrors in interface HttpFilterChain

doFilter

public void doFilter(ServletRequest request,
                     ServletResponse response)
              throws ServletException,
                     IOException
Description copied from interface: HttpFilterChain
Passes the request and response to the next filter.

Specified by:
doFilter in interface FilterChain
Specified by:
doFilter in interface HttpFilterChain
Parameters:
request - the request to pass along in the chain.
response - the response to pass along in the chain.
Throws:
ServletException - for servlet errors.
IOException - for general errors.

doFilter

public void doFilter(ServletRequest request,
                     ServletResponse response,
                     Filter filter)
              throws ServletException,
                     IOException
Description copied from interface: HttpFilterChain
Invokes the specified filter.

Specified by:
doFilter in interface HttpFilterChain
Parameters:
request - the request to pass along in the chain.
response - the response to pass along in the chain.
filter - the filter to invoke.
Throws:
ServletException - for servlet errors.
IOException - for general errors.

doFilter

public void doFilter(ServletRequest request,
                     ServletResponse response,
                     FilterMBeanReference[] filters)
              throws ServletException,
                     IOException
Description copied from interface: HttpFilterChain
Invokes the first filter in a list of filter handles and continues with the rest as long as the preceding filter passes the request forward.

Specified by:
doFilter in interface HttpFilterChain
Parameters:
request - the request to pass along in the chain.
response - the response to pass along in the chain.
filters - an array of filter references.
Throws:
ServletException - for servlet errors.
IOException - for general errors.

terminate

public void terminate()
Description copied from interface: HttpFilterChain
Terminates the filter chain.

Specified by:
terminate in interface HttpFilterChain

getParameter

public String getParameter(String name)
Gets the named request parameter.

Parameters:
name - the name of the parameter.
Returns:
the request parameter or null.

getParameter

public String getParameter(String name,
                           String def)
Gets a named request parameter with a default value.

Parameters:
name - the name of the parameter.
def - the default value.
Returns:
the request parameter or null.

getParameters

public String[] getParameters(String name)
Gets the named request parameters.

Parameters:
name - the name of the parameter.
Returns:
the request parameters or null.

getParameterMap

public Map getParameterMap()
Gets the request parameter map.

Returns:
the request parameter map.

getSession

public HttpSession getSession()
Gets or creates the current session.

Returns:
the session or null if not available.

getLocale

public Locale getLocale()
Gets the current locale.

Returns:
the locale.

getConnector

public ConnectorExtension getConnector()
Gets the connector extension.

Returns:
the extension or null.

getProtocol

public ProtocolExtension getProtocol()
Gets the protocol extension.

Returns:
the extension or null.

getTerminal

public TerminalExtension getTerminal()
Gets the terminal extension.

Returns:
the extension or null.

closeResponse

public void closeResponse()
Closes the current response after committing.


bindToSession

public void bindToSession(ObjectName name)
Binds an MBean to the current session. It will be unregistered automatically when the session expires.

Parameters:
name - the object name of the bound MBean.

releaseFromSession

public void releaseFromSession(ObjectName name)
Releases an MBean from the current session without unregistering.

Parameters:
name - the object name of the bound MBean.

bindToRequest

public void bindToRequest(ObjectName name)
Binds an MBean to the current request. It will be unregistered automatically when the request completes.

Parameters:
name - the object name of the bound MBean.

releaseFromRequest

public void releaseFromRequest(ObjectName name)
Releases an MBean from the current request without unregistering.

Parameters:
name - the object name of the bound MBean.


Copyright © 2004 The Norther Organization. All rights reserved.