责任链模式 - tomcat
Posted Archibald Witwicky
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了责任链模式 - tomcat相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章