org.norther.tammi.spray.filter.chain
Class DefaultFilterChain

java.lang.Object
  extended by org.norther.tammi.core.pool.RecyclableSupport
      extended by org.norther.tammi.spray.filter.chain.DefaultFilterChain
All Implemented Interfaces:
Serializable, FilterChain, Recyclable, HttpFilterChain

public class DefaultFilterChain
extends RecyclableSupport
implements HttpFilterChain

A default implementation of HttpFilterChain.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
DefaultFilterChain()
          Constructs a new chain.
DefaultFilterChain(MBeanServer server)
          Constructs a new chain with a server.
 
Method Summary
 void clearErrors()
          Clears throwables from the error stack of this chain.
 boolean containsErrors()
          Checks whether this chain contains errors.
 void dispose()
          Disposes the object by setting its disposed flag.
 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.
 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.
 MBeanServer getMBeanServer()
          Gets the MBean server.
 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.
 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.
 ServletRequest getRequest()
          Gets the active request.
 ServletResponse getResponse()
          Gets the active response.
 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 recycle(MBeanServer server)
          Recycles a chain with a server.
 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.core.pool.RecyclableSupport
isDisposed, recycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFilterChain

public DefaultFilterChain()
Constructs a new chain.


DefaultFilterChain

public DefaultFilterChain(MBeanServer server)
Constructs a new chain with a server.

Parameters:
server - the MBean server.
Method Detail

recycle

public void recycle(MBeanServer server)
Recycles a chain with a server.

Parameters:
server - the MBean server.

dispose

public void dispose()
Description copied from class: RecyclableSupport
Disposes the object by setting its disposed flag.

Specified by:
dispose in interface Recyclable
Overrides:
dispose in class RecyclableSupport

getRequest

public ServletRequest getRequest()
Description copied from interface: HttpFilterChain
Gets the active request.

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

getResponse

public ServletResponse getResponse()
Description copied from interface: HttpFilterChain
Gets the active response.

Specified by:
getResponse in interface HttpFilterChain
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.

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.

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.

getMBeanServer

public MBeanServer getMBeanServer()
Description copied from interface: HttpFilterChain
Gets the MBean server.

Specified by:
getMBeanServer in interface HttpFilterChain
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


Copyright © 2004 The Norther Organization. All rights reserved.