tomcat启动(四)Catalina分析-server的init()方法
上一回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()方法解释
准备组件启动。此方法应执行任何初始化所需的后期对象创建。
以下生命周期事件将按以下顺序触发:
- 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();
获取注册表,返回MBeanServerinstance实例 oname = register(this, getObjectNameKeyProperties());
}
}
register(this, getObjectNameKeyProperties());
这个方法使子类轻松地注册。不使用MBeanServer实现JmxEnabled的其他组件。
注意:只有在initInternal()被调用之后才能使用此方法,并且在调用destroyInternal()之前。
这个方法将Component实例注册到LifecycleMBeanBase
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()方法的更多相关文章
- tomcat启动(五)Catalina分析-service.init
上篇写到StandardService.init() 这个方法做什么呢?一起来看看. 这个类也是实现了Lifecycle 如图.这个图中i表示Interface接口.如Lifecycle,Contai ...
- tomcat启动(三)Catalina分析-load方法分析
load()方法按从上到下顺序分析(主要分析本人所没学过的知识点,其它略过...). Digester类作用 使用sax技术对xml进行解析 未开始解析时Digester.push(this)这个用来 ...
- tomcat启动(六)Catalina分析-StandardServer.start()
从链接 Tomcat中组件的生命周期管理公共接口Lifecycle 可以知道调用的是StandardServer.startInternal() @Override protected void st ...
- [Tomcat 源码分析系列] (二) : Tomcat 启动脚本-catalina.bat
概述 Tomcat 的三个最重要的启动脚本: startup.bat catalina.bat setclasspath.bat 上一篇咱们分析了 startup.bat 脚本 这一篇咱们来分析 ca ...
- maven项目使用tomcat启动报错:Server Tomcat v8.5 Server at localhost failed to start
背景说明:1)该项目为maven项目,使用的maven的本地仓库里有不少之前使用过下载的jar包: 2)从svn下载该项目后,无报错情况: 3)部署到tomcat启动报错 如下 : 4)在网上搜索了很 ...
- Tomcat 启动提示未发现 APR 的解决方法
Tomcat 启动出现信息如下: 信息: The APR based Apache Tomcat Native library which allows optimal performance in ...
- tomcat启动(三)Catalina简要分析
上篇解析Bootstrap到 daemon.setAwait(true); daemon.load(args); daemon.start(); 这三个方法实际是反射调用org.apache.cata ...
- tomcat启动批处理——catalina.bat
这个批处理才是tomcat服务器启动跟关闭的核心脚本.其中包括....(各种变量),此节将详细讲解这个批处理的逻辑. 先看看第一部分脚本: ****************************** ...
- Tomcat启动脚本catalina.sh
1 - 概述脚本catalina.sh用于启动和关闭tomcat服务器,是最关键的脚本另外的脚本startup.sh和shutdown.sh都是使用不同的参数调用了该脚本该脚本的使用方法如下(引自该脚 ...
随机推荐
- Win & Mac 系统之间U盘传递的U盘文件格式选取问题
Win & Mac 系统之间U盘传递的U盘文件格式选取问题 1. Win系统与Mac系统之间可以通过 exFat U盘文件系统传递 exFAT(Extended File Allocation ...
- C++中的关键字用法--- explicit
1. C++中的explicit C++提供了关键字explicit,可以阻止不应该允许的经过转换构造函数进行的隐式转换的发生.声明为explicit的构造函数不能在隐式转换中使用. C++中, 一个 ...
- java:从消息机制谈到观察者模式
从简单的例子开始 同样,我们还是先看一个简单例子:创建一个窗口实现加法的计算功能.其效果如下: 图1: 加法计算 Calculator.java: import javax.swing.*; impo ...
- hdu 3664 1~n排列(ai>i ) 为k个数
http://acm.hdu.edu.cn/showproblem.php?pid=3664 求1~n的排列个数,使得逆序数(ai>i ) 为给定的k. dp[i][j]表示前1~i的排列中,有 ...
- Socket常用语法与socketserver实例
1>Socket相关: 1>Socket Families(地址簇): socket.AF_UNIX 本机进程间通信 socket.AF_INET IPV4 socket.AF_I ...
- Difference between the Bill of distribution and sourcing rule.
https://forums.oracle.com/thread/936768 This is from a users guide Oracle Supply Chain Planning ...
- [JS] Ajax请求会话过期处理
对于页面来说,处理session过期比较简单,一般只需在过滤器里面判断session用户是否存在,不存在则跳转页面到登陆页即可. 对于Ajax请求来说,这个办法则无效,只能获取到登录页的html代码. ...
- NetCore入门篇:(四)Net Core项目启动文件Startup
一.Startup介绍 1.Startup文件是Net Core应用程的启动程序,实现全局配置. 2.Net Core默认情况下,静态文件及Session都未启动,需要在Startup文件配置启动,否 ...
- gridview获取选中行索引及当前行数据
gridview获取选中行索引及当前行数据 一.非直接绑定数据: <!--前台传值--> <asp:TemplateField HeaderText="操作"&g ...
- 手写数字识别---demo
数据准备 课程中获取数据的方法是从库中直接load_data from keras.datasets import mnist (x_train, y_train), (x_test, y_test) ...