- 浏览: 210991 次
- 性别:
- 来自: 福建省
-
文章分类
最新评论
-
c929833623:
...
Mysql JDBC驱动源码分析(Statement,ResultSet的创建)四 -
pythonlord:
顶 很有帮助,感谢楼主,好人一生平安
Mysql JDBC驱动源码分析(加载驱动)一 -
kiaonly:
代码有错误,我戳。
解释器模式(Interpreter)---java与模式(例子) -
wyzxzws:
小鸟学习了!
JAVA编码问题记录 -
xiaotao.2010:
写的不错! 弱弱说一句 建议使用URL二次转码, 这样可以避免 ...
JAVA编码问题记录
一,进行了以上的类包加载后,现在主要的工作是载入server.xml,并对里面的配置进行解析,最特别的就是里面各个容器的初始化(Server,Service,Engine,Host,Context).
--------------------------------------------------------------------------------------------------------------
Process command line argument (start, startd, stop, stopd)
Class: org.apache.catalina.startup.Bootstrap (assume command->start)
What it does:
a) Catalina.setAwait(true);
b) Catalina.load()
b1) initDirs() -> set properties like
catalina.home
catalina.base == catalina.home (most cases)
b2) initNaming
setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
org.apache.naming.java.javaURLContextFactory ->default)
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.
-------------------------------------------------------------------------------------------------------------
运行到了Bootstrap#main()
else if (command.equals("start")) { daemon.setAwait(true); daemon.load(args); daemon.start(); }
接下去主要讲解tomcat的load()方法
Bootstrap#load(args)
private void load(String[] arguments) throws Exception { // Call the load() method String methodName = "load"; Object param[]; Class paramTypes[]; if (arguments==null || arguments.length==0) { paramTypes = null; param = null; } else { paramTypes = new Class[1]; paramTypes[0] = arguments.getClass(); param = new Object[1]; param[0] = arguments; } //通过反射机制运行Catalina#load()方法 Method method = catalinaDaemon.getClass().getMethod(methodName, paramTypes); if (log.isDebugEnabled()) log.debug("Calling startup class " + method); method.invoke(catalinaDaemon, param); }
接着,查看org.apache.catalina.startup.Catalina#load()
// Start a new server instance.
public void load() { long t1 = System.nanoTime(); //初始化路径 initDirs(); // Before digester - it may be needed initNaming(); // Create and execute our Digester //创建该对象,主要是对conf/server.xml进行解析 Digester digester = createStartDigester(); InputSource inputSource = null; InputStream inputStream = null; File file = null; try { file = configFile();//server.xml文件 inputStream = new FileInputStream(file); inputSource = new InputSource("file://" + file.getAbsolutePath()); } catch (Exception e) { ; } if (inputStream == null) { try { inputStream = getClass().getClassLoader() .getResourceAsStream(getConfigFile()); inputSource = new InputSource (getClass().getClassLoader() .getResource(getConfigFile()).toString()); } catch (Exception e) { ; } } // This should be included in catalina.jar // Alternative: don't bother with xml, just create it manually. if( inputStream==null ) { try { inputStream = getClass().getClassLoader() .getResourceAsStream("server-embed.xml"); inputSource = new InputSource (getClass().getClassLoader() .getResource("server-embed.xml").toString()); } catch (Exception e) { ; } } if ((inputStream == null) && (file != null)) { log.warn("Can't load server.xml from " + file.getAbsolutePath()); return; } try { inputSource.setByteStream(inputStream); //把Catalina这个类压入栈顶部 digester.push(this); //压入顶部之后,在digester中就可以此类与server.xml进行相应的解析,比如该类的server实例化 digester.parse(inputSource); inputStream.close(); } catch (Exception e) { log.warn("Catalina.start using " + getConfigFile() + ": " , e); return; } // Stream redirection initStreams(); // Start the new server if (server instanceof Lifecycle) { try { //StandarServer开始进行实例化 server.initialize(); } catch (LifecycleException e) { log.error("Catalina.start", e); } } long t2 = System.nanoTime(); if(log.isInfoEnabled()) log.info("Initialization processed in " + ((t2 - t1) / 1000000) + " ms"); }
发表评论
-
Nginx1.1实现Resin4集群
2011-10-17 17:56 7334一,web服务器小论 以前的公司使用的web服务器是to ... -
Apache实现Tomcat集群
2010-06-08 20:14 1462一,配置介绍 1,linux 2,tomcat6. ... -
Tomcat源码---容器生命周期管理(Lifecycle)一
2010-03-31 11:12 4503一,tomcat中每一个容器 ... -
Tomcat源码---Session的分析一
2010-03-29 11:31 3881一,前面看了大致的tomcat的请求/响应,接下来的文章对to ... -
Tomcat源码---响应处理五
2010-03-25 16:01 1901一,响应工作我们应该从CoyoteAdapter#servic ... -
Tomcat源码---请求处理四(2)
2010-03-25 15:34 1639对以上的StandardWrapperValve#invok ... -
Tomcat源码---请求处理四(1)
2010-03-25 11:08 1665一,现在到了StandardWrapperValve# ... -
Tomcat源码---请求处理三
2010-03-25 10:39 1393一,这一章节主要讲request与response通过管道,阀 ... -
Tomcat源码---请求处理二
2010-03-24 15:04 1867一,经过以上文章(JIoEndpoint$Worker#run ... -
Tomcat源码---请求处理(接收,线程分配)一
2010-03-24 14:34 2864一,在以上文章中tomcat启动已经完毕,接着要做的是消息的请 ... -
Tomcat源码---容器启动六(4)
2010-03-24 11:14 1497现在容器已经启动成功的StanderService#start ... -
Tomcat源码---容器启动六(3)
2010-03-24 10:48 2314一,容器已经启动到部暑文件(webapps),接下去是Stan ... -
Tomcat源码---容器启动六(2)
2010-03-23 16:42 1531super.start()--->org.apach ... -
Tomcat源码---容器启动六(1)
2010-03-22 16:02 1557一,完成了以上的初始化工作,现在进行容器的启动工作由 ... -
Tomcat源码---初始化容器五
2010-03-22 15:03 1862一,上面文章完成了对server.xml载入以及解析,现在主要 ... -
Tomcat源码---载入相应的资源及解析四(2)
2010-03-19 16:47 1541一,根据以上文章所讲的对server.xml的解析作下简单的分 ... -
Tomcat源码---启动.初始化(加载类包)分析三
2010-03-19 15:37 2256一,启动 Tomcat是从org.apache.catali ... -
Tomcat的简单了解二
2010-03-19 14:40 1875在查看源代码时,在网上找了一系列的文章,在些作详解: ... -
Tomcat中server.xml的配置分析一
2010-03-19 14:07 1842最近查看了tomcat6的源代码,了解了里面的大概 ...
相关推荐
【标题】"Tomcat源码分析系列文档"深入解析了Apache Tomcat服务器的内部工作原理,涵盖了一系列关键知识点,如HTTP协议、类加载机制、容器设计模式等。这些文档为理解Tomcat的运行机制提供了宝贵的资源。 【描述】...
标题:“flex-web工程载入tomcat下xml文件(含源码)”—— 这表明我们将讨论一个Flex Web应用程序,它能够从Tomcat服务器上加载XML配置或数据文件。源码的提供意味着我们将通过具体的代码示例来理解这一过程。 ...
(附件中提供了该工具包的jar包,及源文件以供研究) BeanUtils Commons-BeanUtils 提供对 Java 反射和自省API的包装 Betwixt Betwixt提供将 JavaBean 映射至 XML 文档,以及相反映射的服务. Chain Chain 提供...
2.修正了tomcat资源载入错误的bug; 3.修正了tomcat配置文件载入失败的bug; 4.修正了tomcat读取xml文件核心错误。 真正实现第一个OpenASP的可用版本! 编译版本如何使用: 1.安装jdk1.7,并配置好环境变量;...
嵌入式八股文面试题库资料知识宝典-华为的面试试题.zip
训练导控系统设计.pdf
嵌入式八股文面试题库资料知识宝典-网络编程.zip
人脸转正GAN模型的高效压缩.pdf
少儿编程scratch项目源代码文件案例素材-几何冲刺 转瞬即逝.zip
少儿编程scratch项目源代码文件案例素材-鸡蛋.zip
嵌入式系统_USB设备枚举与HID通信_CH559单片机USB主机键盘鼠标复合设备控制_基于CH559单片机的USB主机模式设备枚举与键盘鼠标数据收发系统支持复合设备识别与HID
嵌入式八股文面试题库资料知识宝典-linux常见面试题.zip
面向智慧工地的压力机在线数据的预警应用开发.pdf
基于Unity3D的鱼类运动行为可视化研究.pdf
少儿编程scratch项目源代码文件案例素材-霍格沃茨魔法学校.zip
少儿编程scratch项目源代码文件案例素材-金币冲刺.zip
内容概要:本文深入探讨了HarmonyOS编译构建子系统的作用及其技术细节。作为鸿蒙操作系统背后的关键技术之一,编译构建子系统通过GN和Ninja工具实现了高效的源代码到机器代码的转换,确保了系统的稳定性和性能优化。该系统不仅支持多系统版本构建、芯片厂商定制,还具备强大的调试与维护能力。其高效编译速度、灵活性和可扩展性使其在华为设备和其他智能终端中发挥了重要作用。文章还比较了HarmonyOS编译构建子系统与安卓和iOS编译系统的异同,并展望了其未来的发展趋势和技术演进方向。; 适合人群:对操作系统底层技术感兴趣的开发者、工程师和技术爱好者。; 使用场景及目标:①了解HarmonyOS编译构建子系统的基本概念和工作原理;②掌握其在不同设备上的应用和优化策略;③对比HarmonyOS与安卓、iOS编译系统的差异;④探索其未来发展方向和技术演进路径。; 其他说明:本文详细介绍了HarmonyOS编译构建子系统的架构设计、核心功能和实际应用案例,强调了其在万物互联时代的重要性和潜力。阅读时建议重点关注编译构建子系统的独特优势及其对鸿蒙生态系统的深远影响。
嵌入式八股文面试题库资料知识宝典-奇虎360 2015校园招聘C++研发工程师笔试题.zip
嵌入式八股文面试题库资料知识宝典-腾讯2014校园招聘C语言笔试题(附答案).zip
双种群变异策略改进RWCE算法优化换热网络.pdf