The Study of Tomcat Source Code -- Part I
来源:互联网 发布:中小学远程教育软件 编辑:程序博客网 时间:2024/05/17 07:38
Tomcat is a big 'box'.
For a simple example from "How Tomcat Works". To build a Tomcat, a 'container' will be used. As we know a big box can contain a small one. In tomcat. there are four kinds of box, hierarchically , Engine, Host, Context, Wrapper. They are all interface.
For a simple illustrate, we take 'Context' and 'Wrapper' as the base containers in this article.
At first we declare a Object simpleContext from the class 'SimpleContext' which implements the Context.
Then declare two Object simpleWrapper from the class 'SimpleWrapper' which implements the Wrapper and are put into the simpleContext.
Well, box is ok. but box must have the tomcat work as a web server.
So something must be put into box: a connector.
The connector is help to work as a ServerSocket to produce socket for the biggest box.It implements Runnable to run itself in a independent thread. It create a serverSocket and hold it. When it starts, several HttpProcessors will be created, which is help to do some preparation, implementing runnable interface. When no socket is accepted, HttpProcessors is running but keep waiting. When connector's serverSocket accept a socket, connector pass the socket to one of the HttpProcessors.HttpProcessors get the request and response from socket.
Here,the simpleContext is the biggest container, which is installed with connector(s),Wrapper(s).
After HttpProcessors's work, HttpProcessors get its container(connector set for them) and then call container's invoke method.
Well, container use a pipeline to process a request. In a pipeline there are many 'valves' ,which type is interface. Every instantiation of valve is an action to a request. Generally the basic Valve action is the servlet being request.
Wrapper is help to represent an executor of a servlet. It can be set Name and ClassName to map a servlet.
When context's initialed , At first a 'simpleContextValve'(class implements valve interface ) is created and was set as the basic valve. Then many other valves(being instantiated) added into pipeline. Well here the simlpeContextValve is just a classifer to choose which serlvet to be called. These servlets to be call are their children Wrappers.
So we need some wrapper with name and classname to be add into the context's child set which help to execute the basic valves.
At last, we need a mapper to help choose the child and a loader to help with load the class of serlvet, which are also need to be added into context.
- The Study of Tomcat Source Code -- Part I
- The study of Tomcat Source Code -- Party II
- Study of Source code
- source code study
- The source code of a greedy snake game I wrote in Turbo C 2.0 lately
- Windows 2000 Kernel Source Code Analysis-Part I
- The Annotated ATI SDK BSP Tree Source Part I:Theory
- Android Source Code Study (0)
- How to find the source code of the special command?
- The Logbook of Qt Source Code Reading(1)
- The Source Code of ActionScript 3 Cookie class
- Chapter 1 A Guided Tour Of The MySQL Source Code
- Free Philosophy: Part I The Beauty of Doubt
- C++ and The Perils of Double-Checked Locking: Part I
- Source Code of exe2com.
- Source Code of exe2com
- Source code of CIH
- Source code of ZMRP_VSS_CLEANUP
- 收缩数据库
- PHP 使用header函数设置HTTP头的示例方法 表头
- UISegmentedControl 分段控件
- 仁科和Microsoft Active Directory安装单点登录
- 关于数据库语句小记(一)
- The Study of Tomcat Source Code -- Part I
- phpExcel常用方法详解【附有php导出excel加超级链接】
- Vim中C/C++代码补全插件-omnicppcomplete
- android使用html开发软件界面
- Ubuntu 12.04中文输入法的安装
- Ubuntu下配置调试phpxdebug)
- 触摸屏当触摸板使用-HID Devices
- iPhone开发笔记——iOS的Base64编码
- 最近16款免费的Wordpress主题