需要了解知识:
1.IO模型:参考 IO与操作系统关系(一) JAVA几种IO工作机制及特点(二)
2.jetty容器: 参考 JETTY基本架构
1.jetty 模块分析
详细参考官网:http://wiki.eclipse.org/Jetty/Reference/Dependencies (jetty模块依赖)
1.1 jetty依赖树:
This diagram shows the compile dependencies for the Jetty project. The external dependencies are listed on the right hand side and all other modules shown are part of the project.
1.2 jetty核心模块(http客户端 服务端通讯模块)
(官方解释)The jetty-util, jetty-io and jetty-http jars form the core of the jetty HTTP handler (generation and parsing) that is used for both the jetty-client and the jetty-server。
如下图:
我们平常最关心的就是 client 如何 server进行通讯,如何实现io通讯的,所以以下几个模块需要了解:
jetty-client:
jetty-server:
jetty-http:
jetty-io:
jetty-util:
1.3 jetty模块结构分析
注:下面讲解jetty核心代码类是用到jetty8中的selectChannelConnector,这里大家参考jetty8 API,jetty9已更换实现类为ServerConnector:
jetty8 api:http://download.eclipse.org/jetty/8.1.17.v20150415/apidocs/
1.3.1 添加依赖jetty插件,从search.maven.org 下载:
<!-- jetty -->
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all-server</artifactId>
<version>8.1.18.v20150929</version>
</dependency>
依赖组件如下: