Tomcat介紹

Server

1.1 In the Tomcat world, a Server represents the whole container. Tomcat provides a default implementation of the Server interface., and this is rarely customized by users. 

1.2 tomcat的世界裏,一個server代表整個容器.Tomcat提供了一個默認的org.apache.catalina接口的實現.用戶很少修改這個默認的實現

 

Service

2.1 Service is an intermediate component which lives inside a Server and ties one or more Connectors to exactly one Engine. The Service element is rarely customized by users, as the default implementation is simple and sufficient: Service interface

2.2 一個Service是一箇中間件,存在在一個Server的內部,將一個或者多個Connectors綁定到一個特定的Engine.默認的實現已經足夠用了.org.apache.catalina.Service接口的一個實現.

A "Service" is a collection of one or more "Connectors" that share a single "Container"

一個Service是一個或者多個Connectors的集合,這些個Connectors共享一個容器。

Engine

3.1 An Engine represents request processing pipeline for a specific Service. As a Service may have multiple Connectors, the Engine received and processes all requests from these connectors, handing the response back to the appropriate connector for transmission to the client. The Engine interface may be implemented to supply custom Engines, though this is uncommon. 

3.2 一個Engine代表一個特定的Service的請求處理的管道.因爲一個Service可以有多個Connectors,Engine接收並且處理從這些Connectors過來的所有的請求.並且將結果送回合適的connector併發送給客戶端.

3.3 可以實現org.apache.catalina.Interface Engine接口來提供定製的Engines,雖然一般不需要這樣做.

3.4 Note that the Engine may be used for Tomcat server clustering via the jvmRoute parameter. Read the Clustering documentation for more information. 

Host

4.1 Host is an association of a network name, e.g. www.yourcompany.com, to the Tomcat server. An Engine may contain multiple hosts, and the Host element also supports network aliases such as yourcompany.com and abc.yourcompany.com. Users rarely create custom Hosts because the StandardHost implementation provides significant additional functionality. 

4.2 一個Host將一個域名和tomcat聯繫起來.一個Engine可以包含多個hosts,並且一個Host還支持網絡別名(例如yourcompany.com 或者 abc.yourcompany.com).用戶很少去實現一個org.apache.catalina.Interface Host接口,因爲org.apache.catalina.core.StandardHost這個默認的實現已經提供了豐富的擴展功能了

 

Connector

5.1 A Connector handles communications with the client. There are multiple connectors available with Tomcat, all of which implement the Connector interface. These include the Coyote connector which is used for most HTTP traffic, especially when running Tomcat as a standalone server, and the JK2 connector which implements the AJP procotol used when connecting Tomcat to an Apache HTTPD server. Creating a customized connector is a significant effort. 

5.2 一個Connector處理和客戶端的通信.tomcat有多個connectors.這些個connectors都實現了Connector接口.

5.3 創建一個定製的connector是非常複雜的.

5.4 AJP是爲TomcatHTTP服務器之間通信而定製的協議,能提供較高的通信速度和效率。在配置TomcatHTTP服務器集成中,讀者可以不必關心AJP協議的細節。關於AJP的知識也可以參考網址:

5.5 Tomcat最主要的功能是提供Servlet/JSP容器,儘管它也可以作爲獨立的Java Web服務器,它在對靜態資源(如HTML文件或圖像文件)的處理速度,以及提供的Web服務器管理功能方面都不如其他專業的HTTP服務器,如IISApache服務器。

5.6 因此在實際應用中,常常把Tomcat與其他HTTP服務器集成。對於不支持Servlet/JSPHTTP服務器,可以通過Tomcat服務器來運行Servlet/JSP組件。

5.7 Tomcat與其他HTTP服務器集成時,Tomcat服務器的工作模式通常爲進程外的Servlet容器,Tomcat服務器與其他HTTP服務器之間通過專門的插件來通信。

5.8 TomcatHTTP服務器集成的原理Tomcat服務器通過Connector連接器組件與客戶程序建立連接,Connector組件負責接收客戶的請求,以及把Tomcat服務器的響應結果發送給客戶。默認情況下,Tomcatserver.xml中配置了兩種連接器:

<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

5.9 第一個連接器監聽8080端口,負責建立HTTP連接。在通過瀏覽器訪問Tomcat服務器的Web應用時,使用的就是這個連接器。 

5.10 第二個連接器監聽8009端口,負責和其他的HTTP服務器建立連接。在把Tomcat與其他HTTP服務器集成時,就需要用到這個連接器。

5.11 Tomcat提供了專門的JK插件來負責TomcatHTTP服務器的通信。應該把JK插件安置在對方的HTTP服務器上。

5.12 對於不同的HTTP服務器,Tomcat提供了不同的JK插件的實現模塊

Windows下的Apache HTTP服務器集成:mod_jk_2.0.46.dll 

LinuxRedHet)下的Apache HTTP服務器集成:mod_jk.so-ap2.0.46-rh72..46-rh72 

IIS服務器集成:isapi_redirect.dll

5.13 AJP是爲TomcatHTTP服務器之間通信而定製的協議,能提供較高的通信速度和效率。

5.14 關於AJP的知識也可以參考網址:
http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk2/doc/common/AJPv13.html

5.15 如果兩個Tomcat服務器都在同一臺機器上運行,則至少應該對其中一個Tomcat服務器的以上3個端口號都進行修改。

Context

6.1 Context represents a web application. A Host may contain multiple contexts, each with a unique path. The Context interface may be implemented to create custom Contexts, but this is rarely the case because the StandardContext provides significant additional functionality. 

6.2 一個Context代表一個web應用程序。一個Host可以包含多個contexts。每一個有不同的訪問地址。

可以實現Context接口來創建自己的Contexts。但很少這樣用,因爲StandardContext已經提供了豐富的額外的功能


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章