Rakesh API

org.rakeshv.filters
Class FilterAdapter

java.lang.Object
  extended by org.rakeshv.filters.FilterAdapter
All Implemented Interfaces:
javax.servlet.Filter
Direct Known Subclasses:
CachingFilter, CompressionFilter

public class FilterAdapter
extends java.lang.Object
implements javax.servlet.Filter

A Filter class that implements the Filter interface, and provides default implementations for all the methods. In most cases, sub-classes need only over-ride the doFilter( ServletRequest, ServletResponse, FilterChain ) method.

© Copyright 2003, Rakesh Vidyadharan

Version:
$Id: FilterAdapter.java,v 1.4 2005/09/16 13:21:38 rakesh Exp $
Author:
Rakesh Vidyadharan 2nd September 2003

Field Summary
protected  javax.servlet.FilterConfig filterConfig
          A reference to the Servlet container's Filter configuration.
 
Constructor Summary
FilterAdapter()
           
 
Method Summary
 void destroy()
          Called by the web container to indicate to a filter that it is being taken out of service.
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
          This method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain.
 void init(javax.servlet.FilterConfig filterConfig)
          Called by the web container to indicate to a filter that it is being placed into service.
protected  void setFilterConfig(javax.servlet.FilterConfig filterConfig)
          Set filterConfig.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filterConfig

protected javax.servlet.FilterConfig filterConfig
A reference to the Servlet container's Filter configuration.

Constructor Detail

FilterAdapter

public FilterAdapter()
Method Detail

init

public void init(javax.servlet.FilterConfig filterConfig)
          throws javax.servlet.ServletException
Called by the web container to indicate to a filter that it is being placed into service. The servlet container calls the init method exactly once after instantiating the filter. The init method must complete successfully before the filter is asked to do any filtering work.

Specified by:
init in interface javax.servlet.Filter
Parameters:
filterConfig - - A filter configuration object used by a servlet container used to pass information to a filter during initialization. This is used to set the filterConfig reference.
Throws:
javax.servlet.ServletException - - If an exception is encountered while fetching the initialisation parameters from the filterConfig object reference.

destroy

public void destroy()
Called by the web container to indicate to a filter that it is being taken out of service. This method is only called once all threads within the filter's doFilter method have exited or after a timeout period has passed. After the web container calls this method, it will not call the doFilter method again on this instance of the filter. Just sets the filterConfig reference to null.

Specified by:
destroy in interface javax.servlet.Filter

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
This method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain. The FilterChain passed in to this method allows the Filter to pass on the request and response to the next entity in the chain.

The default implementation simply passes control on to the next filter in the chain.

Specified by:
doFilter in interface javax.servlet.Filter
Throws:
java.io.IOException - - If exceptions are encountered while applying the filter.
javax.servlet.ServletException - - If exceptions are encountered while interacting with the request or response objects.

setFilterConfig

protected void setFilterConfig(javax.servlet.FilterConfig filterConfig)
Set filterConfig.

Parameters:
filterConfig - The value to set.

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan