浅析Tomcat之Pipeline和Value
来源:互联网 发布:东南大学软件测试专业 编辑:程序博客网 时间:2024/06/09 21:09
Tomcat的容器中,内容的执行是通过一个管道来控制的,它定义了一个Pipeline,4个层次的容器都持有了一个Pipeline用以执行预定义好的任务.而具体的任务则装载在Value中,也就是所谓的阀.
我们知道在连接适配器中的服务方法通过了调用connector.getService().getContainer().getPipeline().getFirst().invoke(request, response)的调用将请求转移到容器中执行.它实际就是调用了容器的Pipeline中的任务,即依次执行预定义好的任务(Value).Pipeline的实现是一个链表结构.我们先看看它其中的节点实现.
public abstract class ValveBase extends LifecycleMBeanBase implements Contained, Valve{ /** * The next Valve in the pipeline this Valve is a component of. */ protected Valve next = null; @Override public Container getContainer() { return (container); } @Override public void setContainer(Container container) { this.container = container; } @Override public Valve getNext(){ return (next); } @Override public void setNext(Valve valve){ this.next = valve; } @Override public abstract void invoke(Request request, Response response) throws IOException, ServletException; @Override public void event(Request request, Response response, CometEvent event) throws IOException, ServletException { // Perform the request getNext().event(request, response, event); }}
上述精简过的代码是实现了Value接口的基础类ValueBase,它有一个Value类型的内部属性next,即同一个Pipeline中的后续Value的引用.如果玩过Java数据结构或作STL的基本上不难理解这是一个单向链表的节点.继承这个ValueBase针对不同的容器实现了不同版本的阀如StandardEngineValue,StandardHostValue,StandardContextValue,StandardWrapperValve等.他们之间不同的实现就是invoke和event的方法不同.而实际上也就是请求的路由选择,Filter应用和Servlet的处理(此部分内容后续博文解释).
Pipeline的标准实现是StandardPipeline.它的类注释是Standard implementation of a processing Pipeline that will invoke a series of Valves that have been configured to be called in order.This implementation can be used for any type of Container.意思是它用于依次执行已经配置好的阀.
- 浅析Tomcat之Pipeline和Value
- Tomcat处理Http请求和Pipeline机制
- jenkins插件之Build Pipeline Plugin和Delivery Pipeline Plugin
- PipeLine and Value
- 浅析WebLogic和Tomcat
- Tomcat源码阅读之Container与Pipeline的设计
- Tomcat请求处理(四) -- Request, Response, 和Pipeline
- Tomcat 管道 Pipeline
- 关于Tomcat的Pipeline机制
- tomcat:pipeline与valve机制
- Jedis之pipeline
- Redis 之 Pipeline
- pipeline之Hazards
- TBB之pipeline
- Jedis之pipeline
- Jedis之pipeline
- Spark之pipeline机制
- 浅析Tomcat之Coyote连接器架构分析
- golang获取昨天的日期
- 机器学习入门(一)朴素贝叶斯解析
- OC对文本的操作
- [Business Intelligence] 1NF, 2NF, 3NF
- ie 7/8/9 placeholder 不显示 解决方案
- 浅析Tomcat之Pipeline和Value
- IntelliJ IDEA 使用心得与常用快捷键
- HDU1285(拓扑排序+优先队列)
- AndroidSDK版本和API版本对于关系
- Singleton模式的实现方式 C#
- JAVA中使用Formatter类进行输出格式的控制
- IQKeyboardManager使用方法
- 基于Web在线考试系统的设计与实现
- 【jQuery】sele1,sele2,seleN选择器