Tmocat的service.xml配置文件詳解(含中文翻譯)
阿新 • • 發佈:2018-07-28
bean ssl eth call 項目 redirect 類型 describe update
Tmocat的service.xml配置文件 | |
英文原版 | 中文手譯 |
<?xml version=‘1.0‘ encoding=‘utf-8‘?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!--################Server################################--> <!-- Note: A "Server" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/server.html --> <Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <!-- Security listener. Documentation at /docs/config/listeners.html <Listener className="org.apache.catalina.security.SecurityListener" /> --> <!--APR library loader. Documentation at /docs/apr.html --> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <!-- Prevent memory leaks due to use of particular java/javax APIs--> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <!-- Global JNDI resources Documentation at /docs/jndi-resources-howto.html --> <GlobalNamingResources> <!-- Editable user database that can also be used by UserDatabaseRealm to authenticate users --> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> </GlobalNamingResources> <!--#################Service###############################--> <!-- A "Service" is a collection of one or more "Connectors" that share a single "Container" Note: A "Service" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/service.html --> <Service name="Catalina"> <!--The connectors can use a shared executor, you can define one or more named thread pools--> <!-- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/> --> <!--#################Connector###############################--> <!-- A "Connector" represents an endpoint by which requests are received and responses are returned. Documentation at : Java HTTP Connector: /docs/config/http.html (blocking & non-blocking) Java AJP Connector: /docs/config/ajp.html APR (HTTP/AJP) Connector: /docs/apr.html Define a non-SSL/TLS HTTP/1.1 Connector on port 8080 --> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URLEncoding="utf-8"/> <!-- A "Connector" using the shared thread pool--> <!-- <Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> --> <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443 This connector uses the NIO implementation that requires the JSSE style configuration. When using the APR/native implementation, the OpenSSL style configuration is required as described in the APR/native documentation --> <!-- <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" /> --> <!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> <!--##############Engine##################################--> <!-- An Engine represents the entry point (within Catalina) that processes every request. The Engine implementation for Tomcat stand alone analyzes the HTTP headers included with the request, and passes them on to the appropriate Host (virtual host). Documentation at /docs/config/engine.html --> <!-- You should set jvmRoute to support load-balancing via AJP ie : <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1"> --> <Engine name="Catalina" defaultHost="localhost"> <!--For clustering, please take a look at documentation at: /docs/cluster-howto.html (simple how to) /docs/config/cluster.html (reference documentation) --> <!-- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> --> <!-- Use the LockOutRealm to prevent attempts to guess user passwords via a brute-force attack --> <Realm className="org.apache.catalina.realm.LockOutRealm"> <!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <!--#################Host###############################--> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> </Engine> </Service> </Server> |
<?xml version = "1.0" encoding = ‘uft-8‘?>
<!--
在一個或多個貢獻者許可協議下授權給Apache軟件基金會(ASF)。
請參閱通知文件分發的關於版權所有權的其他信息。Apache軟件基金會
在Apache許可證(2.0)下授權該文件給您。除非符合許可證,否則不得
使用此文件。你可以在
http://www.apache.org/licenses/LICENSE-2.0
獲得一個許可證的副本。
除非適用法律要求或書面同意,在許可證下分發的軟件在“以此類推”的基礎
上分發,無論任何類型的保證或條件,無論明示還是暗示。查看許可證下限
定的特定語言和權限的許可證。
-->
<!--###################Server#####################-->
<!-- 註意:一個“服務器”他本身不是一個“容器”,所以你不能在這個級別上
定義諸如“Valves”子組件。
文件在/docs/.config/service.html下
-->
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<!-- 全面的JNDI(Java naming and directory interface)資源
文件在/docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- 可編輯用戶數據,也可以由UserDatabaseRealm認證用戶。
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<!--<Server>頂層容器
1.Server的主要任務:
提供一個接口讓客戶端能夠訪問到這個Service集合,同時維護它所包含
的所有的Service的聲明周期,包括如何初始化、如何結束服務、如何找到
客戶端要訪問的Service。
2.Server的屬性:
|
1、整體關系
核心組件之間的整體關系,在上一部分有所介紹,這裏總結一下:
Server元素在最頂層,代表整個Tomcat容器;一個Server元素中可以有一個或多個Service元素。
Service在Connector和Engine外面包了一層,把它們組裝在一起,對外提供服務。一個Service可以包含多個Connector,但是只能包含一個Engine;Connector接收請求,Engine處理請求。
Engine、Host和Context都是容器,且 Engine包含Host,Host包含Context。每個Host組件代表Engine中的一個虛擬主機;每個Context組件代表在特定Host上運行的一個Web應用。
2、如何確定請求由誰處理?當請求被發送到Tomcat所在的主機時,如何確定最終哪個Web應用來處理該請求呢?(1)根據協議和端口號選定Service和EngineService中的Connector組件可以接收特定端口的請求,因此,當Tomcat啟動時,Service組件就會監聽特定的端口。在第一部分的例子中,Catalina這個Service監聽了8080端口(基於HTTP協議)和8009端口(基於AJP協議)。當請求進來時,Tomcat便可以根據協議和端口號選定處理請求的Service;Service一旦選定,Engine也就確定。 通過在Server中配置多個Service,可以實現通過不同的端口號來訪問同一臺機器上部署的不同應用。(2)根據域名或IP地址選定HostService確定後,Tomcat在Service中尋找名稱與域名/IP地址匹配的Host處理該請求。如果沒有找到,則使用Engine中指定的defaultHost來處理該請求。在第一部分的例子中,由於只有一個Host(name屬性為localhost),因此該Service/Engine的所有請求都交給該Host處理。(3)根據URI選定Context/Web應用這一點在Context一節有詳細的說明:Tomcat根據應用的 path屬性與URI的匹配程度來選擇Web應用處理相應請求,這裏不再贅述。(4)舉例以請求http://localhost:8080/app1/index.html為例,首先通過協議和端口號(http和8080)選定Service;然後通過主機名(localhost)選定Host;然後通過uri(/app1/index.html)選定Web應用。 |
|
一個Server可以包含多個Service,不同的Service用來監聽不同的端口。 一個Service可以包含多個Connector,但是只能包含一個Engine。 Tomcat可以提供多個Server Server:對外提供接口(一個Server可以有多個Service) Service:對外提供服務(一個Service可以包含多個Connector,但是只能包含一個Engine) Connector:接受客戶端請求(一個Service可以包含多個Connector) Engine:處理接受進來的請求(一個Service只能包含一個Engine) Host:運行Web應用程序(一個Engine至少有一個Host) |
參考鏈接:
|
Tmocat的service.xml配置文件詳解(含中文翻譯)