bb.servlet
Class AbstractFilter

java.lang.Object
  extended by bb.servlet.AbstractFilter
All Implemented Interfaces:
Filter
Direct Known Subclasses:
CacheDisablingFilter

public abstract class AbstractFilter
extends Object
implements Filter

This abstract filter class implements some functionality that will likely be common to all filters: a filterConfig field, as well as init, destroy, and toString methods. The doFilter method is left for concrete subclasses to implement.

This class is multithread safe: its only state is the filterConfig field which is declared volatile.

Author:
Brent Boyer

Field Summary
protected  FilterConfig filterConfig
          The filter configuration object we are associated with.
 
Constructor Summary
AbstractFilter()
           
 
Method Summary
 void destroy()
          Takes this filter out of service.
abstract  void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
          To be implemented by a concrete subclass.
 void init(FilterConfig filterConfig)
          Places this filter into service.
 String toString()
          Returns a String representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

filterConfig

protected volatile FilterConfig filterConfig
The filter configuration object we are associated with. If null, this filter instance is not currently configured.

Constructor Detail

AbstractFilter

public AbstractFilter()
Method Detail

init

public void init(FilterConfig filterConfig)
          throws ServletException
Places this filter into service. The implementation here merely stores the filterConfig arg into the filterConfig field.

Specified by:
init in interface Filter
Parameters:
filterConfig - The filter configuration object
Throws:
ServletException

destroy

public void destroy()
Takes this filter out of service. The implementation here merely sets the filterConfig field to null. Therefore, this instance will be left unconfigured once this method exits.

Specified by:
destroy in interface Filter

doFilter

public abstract void doFilter(ServletRequest request,
                              ServletResponse response,
                              FilterChain chain)
                       throws IOException,
                              ServletException
To be implemented by a concrete subclass.

Specified by:
doFilter in interface Filter
Parameters:
request - The servlet request we are processing
response - The servlet response we are creating
chain - The filter chain we are processing
Throws:
IOException - if an input/output error occurs
ServletException - if a servlet error occurs

toString

public String toString()
Returns a String representation of this object.

Overrides:
toString in class Object