BaseFilter

BaseFilter
2007-05-29 18:43

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);
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值