Tomcat源码---载入相应的资源及解析四(2)
一,根据以上文章所讲的对server.xml的解析作下简单的分析
org.apache.catalina.startup.Catalina#load
Digester是用sax来解析server.xml的类,这一步是初始化
?
?
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 这本书的第十五章,有详细介绍
?
- inputSource.setByteStream(inputStream);??
- ???????????//把Catalina这个类压入栈顶部??
- ???????????digester.push(this);??
- ????//压入顶部之后,在digester中就可以此类与server.xml进行相应的解析,比如该类的server实例化??
- ???????????digester.parse(inputSource);??
- ???????????inputStream.close(); ?
?
digester.push(this);把该对象压入到栈中,以便为这个类中的属性进行初始化,如Server
digester.parse(inputSource);为对里面所设置的对象进行初始化等一系列操作.