import java.io.IOException;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import org.apache.commons.logging.Log;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.PropertyAccessorFactory;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.PropertyValues;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceEditor;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.context.ServletContextAware;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.ServletContextResourceLoader;
import org.springframework.web.context.support.StandardServletEnvironment;
import org.springframework.web.util.NestedServletException;
import com.pingan.pafa.papp.web.filter.AbstractWebFilter;
import com.pingan.pafa.papp.web.filter.DefFilterConfig;
/**
* 自定义Spring DelegatingFilterProxy, 适应pafa框架, 实现DelegatingFilterProxy功能
*
* 配置步骤: 1.在pafa_sar_spring.xml引入当前自定义过滤器
* 2.注入targetBeanName属性, 指向目标过滤器, 将当前过滤器链跳转交给目标过滤器进行处理
* 3.注入targetFilterLifecycle属性为true, 将目标过滤器生命周期交给spring管理
*/
public class PafaDelegatingFilter extends AbstractWebFilter implements
EnvironmentAware, ServletContextAware, ApplicationContextAware {
protected final Log logger = org.apache.commons.logging.LogFactory.getLog(getClass());
private final Set<String> requiredProperties = new HashSet<String>();
private FilterConfig filterConfig = new DefFilterConfig(this.getBeanName(),null,this.getServletContext());
private String beanName;
private Environment environment = new StandardServletEnvironment();
private ServletContext servletContext;
private String contextAttribute;
private ApplicationContext applicationContext;
private String targetBeanName;
private boolean targetFilterLifecycle = false;
private volatile Filter delegate;