上一回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. Hdu2952 Counting Sheep 2017-01-18 14:56 44人阅读 评论(0) 收藏

    Counting Sheep Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Tota ...

  2. OpenGL常用的函数

    OpenGL常用的函数 1. void glBegin(GLenummode) void glEnd(void) 参数说明: mode:创建图元的类型.可以是以下数值 GL_POINTS:把每一个顶点 ...

  3. spring案列——xml配置

    一.需要的jar包 spring.jar(官网下载) commons-logging.jar 二.项目结构 三.entity(实体类) package com.team.model; public c ...

  4. [ACM_暴力] 最多交换k个数的顺序,求a[i]的最大连续和

    /* http://codeforces.com/contest/426/problem/C 最多交换k个数的顺序,求a[i]的最大连续和 爆解 思路:Lets backtrack interval ...

  5. C#调用C++库知识点

    DllImport方式: CharSet属性:Ansi短字节和Unicode长字节 CallingConvention属性:Cdecl清理和被调用方清理堆栈 EntryPoint属性:定位函数入口.如 ...

  6. 如何使用socket进行java网络编程(二)

    通过在如何使用socket进行java网络编程(一)中程序的编写,可以总结出一些常用的java socket编程的范例来. ServerSocket server = new ServerSocket ...

  7. log4j学习(一)最简单的例子

    前言: 之前笔者一直是在System.out中打日志的,由于笔者大部分时候是编写在tomcat容器里运行的一些个小web应用,所以这么做似乎没什么问题:打印出来的日志都可以在tomcat自己的log目 ...

  8. Comparable接口——容器中自定义类排序

    1.容器TreeMap,默认根据Key对象中某个属性的从小到大排列元素. (1)如下代码示例,Key是整型数字,所以按照其从小到大的顺序排列 public class TestTreeMap { pu ...

  9. C#后端接收form-data,创建实体类

    public class Para_list //实体类 { public long ParemeterID { get; set; } public string Name { get; set; ...

  10. netstat 查看本机开放端口

    root@kali:~# netstat -luntp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Add ...