标签:... tom pre bsp str 责任 private filters cli
class filterChain{ private List<Filter> filters; public void addFilter(Filter filter){ filters.add(filter); } public void do(HttpRequest request){ for(Filter filter:filters){ filter.do(request); } } } public class ConcreateFilter1:Filter{ public void do(HttpRequest request){ // } } public class ConcreateFilter2:Filter{ public void do(HttpRequest request){ // } } public class Client{ public void main(String[] args){ HttpRequest request = ..... FilterChain filterChain = new FilterChain(); filterChain.addFilter(new ConcreateFilter1()); filterChain.addFilter(new ConcreateFilter2()); filterChain.addFilter(new ConcreateFilter2()); filterChain.do(request); } }
标签:... tom pre bsp str 责任 private filters cli
原文地址:http://www.cnblogs.com/hfultrastrong/p/7758182.html