首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Tomcat源码-载入呼应的资源及解析四(2)

2012-10-08 
Tomcat源码---载入相应的资源及解析四(2)一,根据以上文章所讲的对server.xml的解析作下简单的分析org.apac

Tomcat源码---载入相应的资源及解析四(2)

一,根据以上文章所讲的对server.xml的解析作下简单的分析

org.apache.catalina.startup.Catalina#load

Digester是用sax来解析server.xml的类,这一步是初始化

?

  1. //创建该对象,主要是对conf/server.xml进行解析??
  2. ???????Digester?digester?=?createStartDigester();?

?

tomcat文档的解析如下:

--------------------------------------------------------

?

b3) createStartDigester()?

Configures a digester for the main server.xml elements like

org.apache.catalina.core.StandardServer (can change of course :)

org.apache.catalina.deploy.NamingResources

Stores naming resources in the J2EE JNDI tree

org.apache.catalina.LifecycleListener

implements events for start/stop of major components

org.apache.catalina.core.StandardService

The single entry for a set of connectors,

so that a container can listen to multiple connectors

ie, single entry

org.apache.coyote.tomcat5.CoyoteConnector

Connectors to listen for incoming requests only

It also adds the following rulesets to the digester

NamingRuleSet

EngineRuleSet

HostRuleSet

ContextRuleSet

b4) Load the server.xml and parse it using the digester

? ?Parsing the server.xml using the digester is an automatic

? ?XML-object mapping tool, that will create the objects defined in server.xml

? ?Startup of the actual container has not started yet.

b5) Assigns System.out and System.err to the SystemLogHandler class

b6) Calls intialize on all components, this makes each object register itself with the?

? ?JMX agent.

? ?During the process call the Connectors also initialize the adapters.

? ?The adapters are the components that do the request pre-processing.

? ?Typical adapters are HTTP1.1 (default if no protocol is specified,

? ?org.apache.coyote.http11.Http11Protocol)

? ?AJP1.3 for mod_jk etc.


?

--------------------------------------------------------

org.apache.catalina.startup.Catalina#createStartDigester

?

?

?

??//要查看digester的解析可查看how tomcat work 这本书的第十五章,有详细介绍

?

  1. inputSource.setByteStream(inputStream);??
  2. ???????????//把Catalina这个类压入栈顶部??
  3. ???????????digester.push(this);??
  4. ????//压入顶部之后,在digester中就可以此类与server.xml进行相应的解析,比如该类的server实例化??
  5. ???????????digester.parse(inputSource);??
  6. ???????????inputStream.close(); ?

?

digester.push(this);把该对象压入到栈中,以便为这个类中的属性进行初始化,如Server

digester.parse(inputSource);为对里面所设置的对象进行初始化等一系列操作.

热点排行