tomcat#结构

下面是一个tomcat的配置文件,通过分析tomcat配置文件的结构,和相关注释,可以大致了解tomcat的结构

xml version="1.0" encoding="UTF-8"?>


 
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  
  
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  
  <GlobalNamingResources>
    
    <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 name="Catalina">

    
    


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

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


    
     

    
    <Engine name="Catalina" defaultHost="localhost">

      
      

      
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        
        

        
        <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>
View Code

 

 

通过配置文件可以得到下面的图

tomcat#结构_第1张图片

 

 补充:

1. 请求到达connect,需要经过engine判断才知道用tomcat中的那个应用处理请求。

2. Service是一到多个Connector的集合,这些Connector共享一个Container。

 

疑问:

不知道container到底是啥,估计一个启动的tomcat就是一个container,是这样吗?

 

 

你可能感兴趣的:(tomcat#结构)