spring-cloud-starter-alibaba-nacos-discovery

目录

  1. 代码结构
  2. 重要的类

代码结构 

从github下载一下代码,地址如下:
GitHub - alibaba/spring-cloud-alibaba: Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware. - GitHub - alibaba/spring-cloud-alibaba: Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.https://github.com/alibaba/spring-cloud-alibaba/

IDEA中,一共30个类文件。

重要的类

1, NacosAutoServiceRegistration.java  继承一个抽象类 AbstractAutoServiceRegistration.java,这个抽象类属于spring-cloud-commons项目。这个抽象类实现了ApplicationListener接口,监听WebServerInitializedEvent事件。web服务器初始化的时候,发布WebServerInitializedEvent事件,此时回调方法生效。

public void onApplicationEvent(WebServerInitializedEvent event) {
        this.bind(event);
}

public void bind(WebServerInitializedEvent event) {
        ApplicationContext context = event.getApplicationContext();
        if (!(context instanceof ConfigurableWebServerApplicationContext) || !"management".equals(((ConfigurableWebServerApplicationContext)context).getServerNamespace())) {
            this.port.compareAndSet(0, event.getWebServer().getPort());
            this.start();
        }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值