public static void main(String[] args){
com.alibaba.dubbo.container.Main.main(args);
}
如果args为空,则调用SpringContainer.start(),跟常规的spring容器启动方式一模一样,下面分析下start的实现逻辑。
1、从系统参数中读取“dubbo.spring.config”配置的配置文件路径,如果为空,则配置文件路径为classpath*:META-INF/spring/*.xml。
2、spring容器启动。
public void start() {
String configPath = ConfigUtils.getProperty(SPRING_CONFIG);
if (configPath == null || configPath.length() == 0) {
configPath = DEFAULT_SPRING_CONFIG;
}
context = new ClassPathXmlApplicationContext(configPath.split("[,\\s]+"), false);
context.addApplicationListener(new DubboApplicationListener());
context.registerShutdownHook();
context.refresh();
context.start();
}
本文详细解析了Dubbo框架中Spring容器的启动流程。首先检查系统参数中的“dubbo.spring.config”配置,确定配置文件路径,若未配置则使用默认路径。随后,通过ClassPathXmlApplicationContext初始化Spring容器,注册DubboApplicationListener监听器,启动容器并加载配置。
891

被折叠的 条评论
为什么被折叠?



