上一回load()方法解析讲到xml解析完成。

load()内部接下来会获取server

getServer().setCatalina(this);

这个server从createStartDigester()方法中可以看出getServer()返回的是StandardServer对象

具体请看:

Catalina.createDigester方法详细理解

1、接着执行Server.init方法

getServer().init();
看StandardServer类的关系
public final class StandardServer extends LifecycleMBeanBase implements Server
ζ

public abstract class LifecycleMBeanBase extends LifecycleBase
ζ

public abstract class LifecycleBase implements Lifecycle

Lifecycle.init()方法解释

准备组件启动。此方法应执行任何初始化所需的后期对象创建。
以下生命周期事件将按以下顺序触发:
  1. INIT_EVENT: On the successful completion of component initialization成功完成组件初始化

2、由LifecycleBase重写其init()方法,方法里主要调用initInternal方法。这个方法是抽象方法

initInternal();

 3、LifecycleMBeanBase重写initInternal()方法

@Override
protected void initInternal() throws LifecycleException { // If oname is not null then registration has already happened via
// preRegister().
if (oname == null) {
mserver = Registry.getRegistry(null, null).getMBeanServer();
获取注册表,返回MBeanServer instance实例 oname = register(this, getObjectNameKeyProperties());
}
}
register(this, getObjectNameKeyProperties());
这个方法使子类轻松地注册。不使用MBeanServer实现JmxEnabled的其他组件。
注意:只有在initInternal()被调用之后才能使用此方法,并且在调用destroyInternal()之前。
.LifecycleMBeanBase.register(Object obj, String objectNameKeyProperties)
obj:向这个对象注册
objectNameKeyProperties:用于注册对象的对象名称的关键属性组件

这个方法将Component实例注册到LifecycleMBeanBase

4、StandardServer.initInternal() 
super.initInternal();
// Register global String cache
// Note although the cache is global, if there are multiple Servers
// present in the JVM (may happen when embedding) then the same cache
// will be registered under multiple names
onameStringCache = register(new StringCache(), "type=StringCache");
// Register the MBeanFactory
MBeanFactory factory = new MBeanFactory();
factory.setContainer(this);
onameMBeanFactory = register(factory, "type=MBeanFactory");
// Register the naming resources
globalNamingResources.init(); // Initialize our defined Services
for (int i = 0; i < services.length; i++) {
services[i].init();
}

至于这个services是怎么来了,可以看到下面:service只有一个StandardService

Catalina.createDigester方法详细理解

接下来开始执行StandardService.init()

tomcat启动(四)Catalina分析-server的init()方法的更多相关文章

  1. tomcat启动(五)Catalina分析-service.init

    上篇写到StandardService.init() 这个方法做什么呢?一起来看看. 这个类也是实现了Lifecycle 如图.这个图中i表示Interface接口.如Lifecycle,Contai ...

  2. tomcat启动(三)Catalina分析-load方法分析

    load()方法按从上到下顺序分析(主要分析本人所没学过的知识点,其它略过...). Digester类作用 使用sax技术对xml进行解析 未开始解析时Digester.push(this)这个用来 ...

  3. tomcat启动(六)Catalina分析-StandardServer.start()

    从链接 Tomcat中组件的生命周期管理公共接口Lifecycle 可以知道调用的是StandardServer.startInternal() @Override protected void st ...

  4. [Tomcat 源码分析系列] (二) : Tomcat 启动脚本-catalina.bat

    概述 Tomcat 的三个最重要的启动脚本: startup.bat catalina.bat setclasspath.bat 上一篇咱们分析了 startup.bat 脚本 这一篇咱们来分析 ca ...

  5. maven项目使用tomcat启动报错:Server Tomcat v8.5 Server at localhost failed to start

    背景说明:1)该项目为maven项目,使用的maven的本地仓库里有不少之前使用过下载的jar包: 2)从svn下载该项目后,无报错情况: 3)部署到tomcat启动报错 如下 : 4)在网上搜索了很 ...

  6. Tomcat 启动提示未发现 APR 的解决方法

    Tomcat 启动出现信息如下: 信息: The APR based Apache Tomcat Native library which allows optimal performance in ...

  7. tomcat启动(三)Catalina简要分析

    上篇解析Bootstrap到 daemon.setAwait(true); daemon.load(args); daemon.start(); 这三个方法实际是反射调用org.apache.cata ...

  8. tomcat启动批处理——catalina.bat

    这个批处理才是tomcat服务器启动跟关闭的核心脚本.其中包括....(各种变量),此节将详细讲解这个批处理的逻辑. 先看看第一部分脚本: ****************************** ...

  9. Tomcat启动脚本catalina.sh

    1 - 概述脚本catalina.sh用于启动和关闭tomcat服务器,是最关键的脚本另外的脚本startup.sh和shutdown.sh都是使用不同的参数调用了该脚本该脚本的使用方法如下(引自该脚 ...

随机推荐

  1. (二分匹配“匈牙利算法”)无题II --HDU --2236

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=2236 代码: #include<cstdio> #include<cstring> ...

  2. HDU1175 连连看(bfs) 2016-07-24 13:27 115人阅读 评论(0) 收藏

    连连看 Problem Description "连连看"相信很多人都玩过.没玩过也没关系,下面我给大家介绍一下游戏规则:在一个棋盘中,放了很多的棋子.如果某两个相同的棋子,可以通 ...

  3. Why I Want A Wife

    I want a wife who will take care of my physical needs. I want a wife who will keep my house clean. A ...

  4. Oracle sql 优化の索引监控

    1.监视索引是否使用 除了主键是完整性约束而自动变为索引外,创建普通索引的目的就是为了提高查询速度,如果我们创建了索引而没有被使用,那么这些不被使用的索引将起到阻碍性能的作用. 语法: --检查某个索 ...

  5. Java内存模型解惑--观深入理解Java内存模型系列文章有感(二)

    1.volatile关键字修饰的域的特性 当我们声明共享变量为volatile后,对这个变量的读/写将会很特别.理解volatile特性的一个好方法是:把对volatile变量的单个读/写,看成是使用 ...

  6. matlab 生成mat文件

    生成MAT文件 假如你的矩阵A.B都已赋值,现在需要将A,B矩阵保存成mat格式文件,执行如下命令:save mydata A B 就会把A B矩阵数据保存在yourdata.dat文件中了 保存指定 ...

  7. 在循环中使用鼠标悬停时表示当前悬停选中,传入this关键字即可

    在前端循环中使用鼠标悬停事件 <div class="message-widget contact-widget"> <!-- Message --> {% ...

  8. .net Aspose.pdf 转html 去除版权

    时光偷走的,永远都是我们眼皮底下看不见的珍贵. 1. 资源文件 a)     Aspose.pdf.18.12.0.nupkg  链接:https://pan.baidu.com/s/171_OWOf ...

  9. ACTGame项目

    项目地址:https://github.com/alonecat06/ACTGame游戏地址:http://pan.baidu.com/s/1hqD3IYw 项目是一个自制单机动作游戏demo,方向是 ...

  10. Java中的String,StringBuilder,StringBuffer的区别

    这三个类之间的区别主要是在两个方面,即运行速度和线程安全这两方面. 首先说运行速度,或者说是执行速度,在这方面运行速度快慢为:StringBuilder > StringBuffer > ...