atg.filter
Class ConditionalDelegatingFilter

java.lang.Object
  extended by atg.filter.ConditionalDelegatingFilter
All Implemented Interfaces:
javax.servlet.Filter

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

Invokes another "target" filter if that filter is present in the classpath, or does nothing if the filter is not present. The target filter's init and destroy methods are called from this wrapper's init and destroy methods.

The following snippet from a web.xml file would invoke the com.target.filter filter if it exists. The target filter would have access to its someTargetParameter value.

   <filter>
     <filter-name>MyFilterService</filter-name>
     <filter-class>atg.filter.ConditionalDelegatingFilter</filter-class>
     <init-param>
       <param-name>targetFilter</param-name>
       <param-value>com.target.filter</param-value>
     </init-param>
     <init-param>
       <param-name>someTargetParameter</param-name>
       <param-value>someValue</param-value>
     </init-param>
   </filter>
  


Field Summary
static java.lang.String CLASS_NAME_PARAMETER_NAME
           
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String FILTER_CLASS_NAME
           
protected  javax.servlet.Filter mTarget
           
 
Constructor Summary
ConditionalDelegatingFilter()
           
 
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 pRequest, javax.servlet.ServletResponse pResponse, javax.servlet.FilterChain pFilterChain)
          Called by the web container to indicate that a filter should filter a request/response
 void init(javax.servlet.FilterConfig pFilterConfig)
          Called by the web container to indicate to a filter that it is being placed into service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values

FILTER_CLASS_NAME

public static final java.lang.String FILTER_CLASS_NAME
See Also:
Constant Field Values

CLASS_NAME_PARAMETER_NAME

public static final java.lang.String CLASS_NAME_PARAMETER_NAME
See Also:
Constant Field Values

mTarget

protected javax.servlet.Filter mTarget
Constructor Detail

ConditionalDelegatingFilter

public ConditionalDelegatingFilter()
Method Detail

doFilter

public void doFilter(javax.servlet.ServletRequest pRequest,
                     javax.servlet.ServletResponse pResponse,
                     javax.servlet.FilterChain pFilterChain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Called by the web container to indicate that a filter should filter a request/response

Specified by:
doFilter in interface javax.servlet.Filter
Parameters:
pRequest - the servlet request
pServletResponse - the servlet response
pFilterChain - the filter chain
Throws:
java.io.IOException - if an i/o error occurs
javax.servlet.ServletException - if an error occurs when processing this filter

init

public void init(javax.servlet.FilterConfig pFilterConfig)
          throws javax.servlet.ServletException
Called by the web container to indicate to a filter that it is being placed into service.

Specified by:
init in interface javax.servlet.Filter
Parameters:
pFilterConfig - filter configuration information
Throws:
javax.servlet.ServletException

destroy

public void destroy()
Called by the web container to indicate to a filter that it is being taken out of service

Specified by:
destroy in interface javax.servlet.Filter