JAWS模块分析 :: 风之谷
来源: BlogBus 原始链接: http://www.blogbus.com:80/blogbus/blog/diary.php?diaryid=149434 存档链接: https://web.archive.org/web/20041102070130id_/http://www.blogbus.com:80/blogbus/blog/diary.php?diaryid=149434
风之谷 有关ACE/TAO,还有CORBA的学习资料 <<<面向对象的设计原则 | 首页 | JAWS2 分析报告 IV>>> JAWS模块分析 时间:2004-04-19 程序功能说明 http服务器,响应客户端HTTP请求,并提供如下的参数调用接口 -p port number -n threads in the server -f thread activation flags = THR_BOUND = THR_DAEMON = THR_DETACHED = THR_NEW_LWP -t threading strategy = POOL -> thread pool = PER_REQUEST -> thread per request = THROTTLE -> thread per request with throttling -i I/O strategy = SYNCH = ASYNCH -b backlog value for listen () 静态分析 -- 重点是从头文件,主要分析程序构架,类之间的关系以及类的作用 入手,先找程序入口, main.cpp -> 找到 ACE_Service_Config daemon ,通过调用daemon.open进入程序 (关注Service_Config实现) 查看svc.conf 定位服务主程序为HTTP_Server HTTP_Server : public ACE_Service_Object HTTP_Server中包含的内容有 HTTP_SOCK_Acceptor (如何将线程响应模式封装 Task模式的应用) Synch_Thread_Pool_Task Thread_Per_Request_Task Asynch_Thread_Pool_Task (only for window32) HTTP_Server.{h,cpp} 找到 HTTP_Handler.h 和IO.h 分析IO (为什么要单独提出IO处理类) JAWS_IO 抽象接口,提供了基本的IO操作描述 JAWS_IO_Handler 抽象接口,提供了IO操作结果的处理 JAWS_Synch_IO : public JAWS_IO JAWS_Asynch_IO : public JAWS_IO, public ACE_Handler (为什么异步处理需要继承 ACE_Handler) 分析HTTP_Request HTTP_Request This parses the client request of an HTTP transaction. (如何定义解析HTTP_Request) 解析HTTP请求,并将文本信息解析并转换成为HTTP_Request对象中的属性 注意 Values for request type,Header strings 的组织 分析HTTP_Response HTTP_Response Provides an encapsulation of responses to HTTP requests. For instance, given an HTTP GET request, it will produce header and body suitable for returning to the client who made the request. 对HTTP请求的响应封装,--处理请求,并产生响应结果 分析HTTP_Handler HTTP_Handler : protected JAWS_IO_Handler 实现对HTTP协议的处理 The HTTP_Handler class is a state based implementation of the HTTP protocol. Therefore, it can be used synchronously and asynchronously. It uses an abstract IO class to move between different HTTP protocol states. It is up to the IO class to decide on synchronous or asynchronous I/O. (为什么定义friend对象) HTTP_Handler_Factory 定义如何创建新的HTTP handler Synch_HTTP_Handler_Factory : public HTTP_Handler_Factory Asynch_HTTP_Handler_Factory : public HTTP_Handler_Factory, public ACE_Service_Handler (为什么异步模式还需要继承ACE_Service_Handler,其中的Open所起的作用是什么) 剩余文件 HTTP_Config,HTTP_Helpers,Parse_Headers必定是与实现相关的模块 分析HTTP_Config HTTP_Config 存储服务器的相关配置信息 (如何用singleton模式实现有个环境变量的东东) HTTP_Config_Info 实际存储配置信息的地方 分析HTTP_Helpers HTTP_Helpers Static functions to enhance the lives of HTTP programmers everywhere. (为什么要定义这些方法,而且要用static 以及mutex_) HTTP_Status_Code 有关状态码的东东 (singleton的另外一种实现方法) 分析Parse_Headers Headers_Map_Item (Map是什么,Item又是什么) Headers_Map 提供文本头到头值的转换 Headers 完成头到数字的转换 (和Headers_Map有什么关系啊) 模块划分分析 (详见POSA2 ch1.3) 为了保证系统的可扩展性,JAWS设计了相关几个模块 并发模型 Concurrency models e.g.,thread pool vs. thread-per request 事件多路分离模型 Event demultiplexing models e.g.,sync vs. asynch 文件缓存模型(JAW2 提供相应的模型)File caching models e.g.,LRU vs. LFU 内容发送协议模型 Content delivery protocols e.g.,HTTP 1.0+1.1, HTTP-NG, IIOP, DICOM 注:在JAWS2中,将Server分割成为HTTPU和JAWS模块 在HTTPU中负责有个协议内容解析的操作 在JAWS中重点加强了文件缓存部分的处理 jnn 发表于 2004-04-19 17:22 引用Trackback(0) | 编辑 评论 请问: ace 目录中 apps/jaws/ apps/jaws2/ apps/jaws3/ 下的内容有什么区别? 谢谢! Adanz ( ) 发表于 2004-06-08 12:36 apps/jaws/ apps/jaws2/ apps/jaws3/ 是jaws的不同版本。我的这篇文章是以jaws的代码为参考写的。 有关jaws2的代码分析会陆续推出。 jnn ( jnn.blogbus.com ) 发表于 2004-06-08 23:58 发表评论 最后更新 ACE Tutorial [翻译] 04 ACE Tutorial [翻译] 03 ACE Tutorial [翻译] 02-page03 ACE Tutorial [翻译] 02-page02 ACE Tutorial [翻译] 02-page01 ACE Tutorial [翻译] 01-page04 ACE Tutorial [翻译] 01-page03 ACE Tutorial [翻译] 01-page02 ACE Tutorial [翻译]01-page01 ACE 教程 [翻译] (前言)