【文件属性】:
文件名称:JSE基础与设计模式实例
文件大小:5.57MB
文件格式:RAR
更新时间:2015-03-09 07:48:51
JSE基础与设计模式实例
/**
* 作者: jilongliang
* 当前类名:FilterChain.java
* 项目名称:JavaStudy
* 创建时间:2011-12-28
*/
package org.java.com.design.filter;
import java.util.ArrayList;
import java.util.List;
public class FilterChain implements Filter {
List filters = new ArrayList();
int index = 0;
public FilterChain addFilter(Filter f) {
this.filters.add(f);
return this;// 返回this可以连续添加.
}
@Override
public void doFilter(Request request, Response response, FilterChain chain) {
if (index == filters.size())
return;
Filter filter = filters.get(index);
index++;
filter.doFilter(request, response, chain);
}
}