package com.cn.filter;
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Michael J Chane
* @version $Revision: 1.5 $ $Date: 2006/09/04 14:43:18 $
*/
public abstract class BaseFilter implements Filter {
/**
* Logger
*/
protected final Log log = LogFactory.getLog(getClass());
/**
* Filter configurations
*/
protected FilterConfig filterConfig;
/**
* Initializations on the filter.
*
* @param filterConfig
* FilterConfig
* @throws ServletException
* if an unexpected servlet exception occurs
*/
public void init(FilterConfig filterConfig) throws ServletException {
log.info("Initializing " + filterConfig.getFilterName());
this.filterConfig = filterConfig;
}
/**
* Releases the allocated resources of the filter.
*/
public void destroy() {
log.info(filterConfig.getFilterName() + " destroyed");
filterConfig = null;
}
/**
* Returns a hash code value for the object.
*
* @return a hash code value for this object.
*/
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(-55555555, 0xb3, this);
}
/**
* Indicates whether some other object is "equal to" this one.
*
* @param obj
* the reference object with which to compare.
* @return <code>true</code> if this object is the same as the obj argument;
* <code>false</code> otherwise.
*/
@Override
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}
/**
* Retrieves a text representation for this object.
*
* @return the text representation
*/
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}