码迷,mamicode.com
首页 > 其他好文 > 详细

责任链模式 - tomcat

时间:2017-10-30 23:59:56      阅读:344      评论:0      收藏:0      [点我收藏+]

标签:...   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);
      }
}

 

责任链模式 - tomcat

标签:...   tom   pre   bsp   str   责任   private   filters   cli   

原文地址:http://www.cnblogs.com/hfultrastrong/p/7758182.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!