3、【Dubbo3.1.1源码】模块发布器DefaultModuleDeployer

这篇博客详细介绍了Dubbo3.1.1中DefaultModuleDeployer的启动流程,包括服务在Spring容器中的初始化、配置中心的加载、元数据中心的建立以及Zookeeper的连接。重点讲解了startConfigCenter和startMetadataCenter方法,深入探讨了配置加载和元数据报告的实现机制。
摘要由CSDN通过智能技术生成

  上一章我们的服务已经注册到spring容器中并完成实例化了,那么spring在实例化完成之后,就会进行一个最终的刷新操作,即方法finishRefresh 在这里会发布ContextRefreshedEvent 事件。dubbo的DubboDeployApplicationListener 实现了ApplicationListener 那么就会执行到onApplicationEvent方法 ,上代码

@Override
    public void onApplicationEvent(ApplicationContextEvent event) {
   
        if (nullSafeEquals(applicationContext, event.getSource())) {
   
            if (event instanceof ContextRefreshedEvent) {
   
								//处理ContextRefreshedEvent事件
                onContextRefreshedEvent((ContextRefreshedEvent) event);
            } else if (event instanceof ContextClosedEvent) {
   
                onContextClosedEvent((ContextClosedEvent) event);
            }
        }
    }

进一步看一下onContextRefreshedEvent方法

	//这里拿到就是DefaultModuleDeployer
	ModuleDeployer deployer = moduleModel.getDeployer();
	Assert.notNull(deployer, "Module deployer is null");
	// 执行DefaultModuleDeployer的start方法
	Future future = deployer.start();

继续start方法

@Override
public Future start() throws IllegalStateException {
   
    // 这个方法其实在第一章中我们忽略的DubboSpringInitializer.
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值