实践Dubbo源码解析

Dubbo 2.7.13

dubbo-parent包含20个一级模块

module description  
dubbo-common    
dubbo-container 容器  
dubbo-serialization 序列化,比如hessian2、protobuf等  
dubbo-remoting 远程通讯,比如mina、netty等  
dubbo-rpc 远程方法调用,比如dubbo、rest等  
dubbo-cluster 集群和负载等  
dubbo-registry 服务注册,比如zookeeper、nacos等  
dubbo-metadata 元数据,比如zookeeper、nacos等  
dubbo-configcenter 配置中心,比如zookeeper、nacos等  
dubbo-config 配置  
dubbo-plugin 插件  
dubbo-filter 过滤器,比如MonitorFilter  
dubbo-monitor 监控  
dubbo-compatible 兼容处理alibaba相关包  
dubbo-dependencies-bom dubbo外部依赖清单  
dubbo-dependencies dubbo外部依赖,比如zookeeper、curator-recipes  
dubbo-all dubbo all in one,所有模块打包为dubbo.jar  
dubbo-distribution 发行  
dubbo-bom dubbo模块清单  
dubbo-demo demo  

dubbo-parent

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit_jupiter_version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-params</artifactId>
        <version>${junit_jupiter_version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>${hamcrest_version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>${mockito_version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib-nodep</artifactId>
        <version>${cglib_version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>

dubbo-all

由于对dubbo各模块依赖的optional为true,意味着需要根据使用需要自行添加第三方依赖,比如使用mina,就添加mina。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>hessian-lite</artifactId>
    <scope>compile</scope>
    <optional>true</optional>
</dependency>
<!-- 所有dubbo模块,optional为true -->
<!-- 以上dubbo模块会一起打包到dubbo.jar-->
<!-- 配置解析 -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
</dependency>
<dependency>
    <groupId>com.alibaba.spring</groupId>
    <artifactId>spring-context-support</artifactId>
</dependency>
<!-- 动态代理 -->
<dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
</dependency>
<!-- netty -->
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
</dependency>
<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
</dependency>
<dependency>
    <groupId>org.yaml</groupId>
    <artifactId>snakeyaml</artifactId>
</dependency>

[INFO] dubbo-parent ………………………………… SUCCESS [ 0.825 s] [INFO] dubbo-common ………………………………… SUCCESS [ 0.500 s] [INFO] dubbo-container ……………………………… SUCCESS [ 0.008 s] [INFO] dubbo-container-api ………………………….. SUCCESS [ 0.022 s] [INFO] dubbo-container-spring ……………………….. SUCCESS [ 0.017 s] [INFO] dubbo-container-log4j ………………………… SUCCESS [ 0.012 s] [INFO] dubbo-container-logback ………………………. SUCCESS [ 0.019 s] [INFO] dubbo-serialization ………………………….. SUCCESS [ 0.004 s] [INFO] dubbo-serialization-api ………………………. SUCCESS [ 0.031 s] [INFO] dubbo-serialization-hessian2 ………………….. SUCCESS [ 0.013 s] [INFO] dubbo-remoting ………………………………. SUCCESS [ 0.006 s] [INFO] dubbo-remoting-api …………………………… SUCCESS [ 0.015 s] [INFO] dubbo-remoting-netty …………………………. SUCCESS [ 0.014 s] [INFO] dubbo-remoting-mina ………………………….. SUCCESS [ 0.015 s] [INFO] dubbo-remoting-grizzly ……………………….. SUCCESS [ 0.016 s] [INFO] dubbo-remoting-netty4 ………………………… SUCCESS [ 0.013 s] [INFO] dubbo-remoting-p2p …………………………… SUCCESS [ 0.013 s] [INFO] dubbo-remoting-http ………………………….. SUCCESS [ 0.013 s] [INFO] dubbo-remoting-zookeeper ……………………… SUCCESS [ 0.012 s] [INFO] dubbo-remoting-etcd3 …………………………. SUCCESS [ 0.013 s] [INFO] dubbo-rpc …………………………………… SUCCESS [ 0.004 s] [INFO] dubbo-rpc-api ……………………………….. SUCCESS [ 0.014 s] [INFO] dubbo-cluster ……………………………….. SUCCESS [ 0.028 s] [INFO] dubbo-serialization-jdk ………………………. SUCCESS [ 0.015 s] [INFO] dubbo-rpc-dubbo ……………………………… SUCCESS [ 0.020 s] [INFO] dubbo-rpc-injvm ……………………………… SUCCESS [ 0.018 s] [INFO] dubbo-rpc-http ………………………………. SUCCESS [ 0.012 s] [INFO] dubbo-rpc-rmi ……………………………….. SUCCESS [ 0.014 s] [INFO] dubbo-rpc-hessian ……………………………. SUCCESS [ 0.014 s] [INFO] dubbo-rpc-http-invoker ……………………….. SUCCESS [ 0.014 s] [INFO] dubbo-rpc-webservice …………………………. SUCCESS [ 0.013 s] [INFO] dubbo-rpc-native-thrift ………………………. SUCCESS [ 0.014 s] [INFO] dubbo-configcenter …………………………… SUCCESS [ 0.005 s] [INFO] dubbo-configcenter-zookeeper ………………….. SUCCESS [ 0.013 s] [INFO] dubbo-metadata ………………………………. SUCCESS [ 0.004 s] [INFO] dubbo-metadata-api …………………………… SUCCESS [ 0.017 s] [INFO] dubbo-registry ………………………………. SUCCESS [ 0.006 s] [INFO] dubbo-registry-api …………………………… SUCCESS [ 0.021 s] [INFO] dubbo-monitor ……………………………….. SUCCESS [ 0.005 s] [INFO] dubbo-monitor-api ……………………………. SUCCESS [ 0.013 s] [INFO] dubbo-filter ………………………………… SUCCESS [ 0.004 s] [INFO] dubbo-filter-validation ………………………. SUCCESS [ 0.016 s] [INFO] dubbo-filter-cache …………………………… SUCCESS [ 0.016 s] [INFO] dubbo-rpc-rest ………………………………. SUCCESS [ 0.019 s] [INFO] dubbo-registry-multicast ……………………… SUCCESS [ 0.015 s] [INFO] dubbo-registry-zookeeper ……………………… SUCCESS [ 0.016 s] [INFO] dubbo-registry-nacos …………………………. SUCCESS [ 0.015 s] [INFO] dubbo-registry-eureka ………………………… SUCCESS [ 0.017 s] [INFO] dubbo-registry-etcd3 …………………………. SUCCESS [ 0.013 s] [INFO] dubbo-registry-consul ………………………… SUCCESS [ 0.015 s] [INFO] dubbo-metadata-report-zookeeper ……………….. SUCCESS [ 0.014 s] [INFO] dubbo-metadata-report-etcd ……………………. SUCCESS [ 0.014 s] [INFO] dubbo-metadata-report-nacos …………………… SUCCESS [ 0.011 s] [INFO] dubbo-metadata-report-redis …………………… SUCCESS [ 0.009 s] [INFO] dubbo-configcenter-nacos ……………………… SUCCESS [ 0.012 s] [INFO] dubbo-configcenter-consul …………………….. SUCCESS [ 0.011 s] [INFO] dubbo-config ………………………………… SUCCESS [ 0.004 s] [INFO] dubbo-config-api …………………………….. SUCCESS [ 0.024 s] [INFO] dubbo-registry-default ……………………….. SUCCESS [ 0.012 s] [INFO] dubbo-monitor-default ………………………… SUCCESS [ 0.014 s] [INFO] dubbo-config-spring ………………………….. SUCCESS [ 0.053 s] [INFO] dubbo-rpc-thrift …………………………….. SUCCESS [ 0.012 s] [INFO] dubbo-rpc-memcached ………………………….. SUCCESS [ 0.014 s] [INFO] dubbo-rpc-redis ……………………………… SUCCESS [ 0.021 s] [INFO] dubbo-plugin ………………………………… SUCCESS [ 0.005 s] [INFO] dubbo-qos …………………………………… SUCCESS [ 0.016 s] [INFO] dubbo-compatible …………………………….. SUCCESS [ 0.011 s] [INFO] dubbo-rpc-xml ……………………………….. SUCCESS [ 0.013 s] [INFO] dubbo-rpc-grpc ………………………………. SUCCESS [ 0.016 s] [INFO] dubbo-registry-redis …………………………. SUCCESS [ 0.016 s] [INFO] dubbo-registry-multiple ………………………. SUCCESS [ 0.014 s] [INFO] dubbo-registry-sofa ………………………….. SUCCESS [ 0.012 s] [INFO] dubbo-demo ………………………………….. SUCCESS [ 0.004 s] [INFO] dubbo-demo-interface …………………………. SUCCESS [ 0.019 s] [INFO] dubbo-demo-xml ………………………………. SUCCESS [ 0.524 s] [INFO] dubbo-demo-xml-provider ………………………. SUCCESS [ 0.011 s] [INFO] dubbo-demo-xml-consumer ………………………. SUCCESS [ 0.012 s] [INFO] dubbo-demo-annotation ………………………… SUCCESS [ 0.005 s] [INFO] dubbo-demo-annotation-provider ………………… SUCCESS [ 0.016 s] [INFO] dubbo-demo-annotation-consumer ………………… SUCCESS [ 0.014 s] [INFO] dubbo-demo-api ………………………………. SUCCESS [ 0.006 s] [INFO] dubbo-demo-api-provider ………………………. SUCCESS [ 0.013 s] [INFO] dubbo-demo-api-consumer ………………………. SUCCESS [ 0.011 s] [INFO] dubbo-demo-servicediscovery-xml ……………….. SUCCESS [ 0.004 s] [INFO] servicediscovery-provider …………………….. SUCCESS [ 0.011 s] [INFO] servicediscovery-consumer …………………….. SUCCESS [ 0.010 s] [INFO] servicediscovery-transfer …………………….. SUCCESS [ 0.004 s] [INFO] servicediscovery-transfer-provider …………….. SUCCESS [ 0.013 s] [INFO] servicediscovery-transfer-consumer-old …………. SUCCESS [ 0.012 s] [INFO] servicediscovery-transfer-consumer …………….. SUCCESS [ 0.009 s] [INFO] dubbo-call-sc ……………………………….. SUCCESS [ 0.006 s] [INFO] dubbo-sc-provider ……………………………. SUCCESS [ 0.037 s] [INFO] dubbo-sc-consumer ……………………………. SUCCESS [ 0.011 s] [INFO] dubbo-call-scdubbo …………………………… SUCCESS [ 0.003 s] [INFO] dubbo-scdubbo-provider ……………………….. SUCCESS [ 0.028 s] [INFO] dubbo-scdubbo-provider2 ………………………. SUCCESS [ 0.009 s] [INFO] dubbo-scdubbo-consumer ……………………….. SUCCESS [ 0.013 s] [INFO] sc-call-dubbo ……………………………….. SUCCESS [ 0.006 s] [INFO] sc-dubbo-provider ……………………………. SUCCESS [ 0.009 s] [INFO] sc-dubbo-consumer ……………………………. SUCCESS [ 0.028 s] [INFO] dubbo-serialization-fastjson ………………….. SUCCESS [ 0.012 s] [INFO] dubbo-serialization-kryo ……………………… SUCCESS [ 0.016 s] [INFO] dubbo-serialization-fst ………………………. SUCCESS [ 0.019 s] [INFO] dubbo-serialization-protostuff ………………… SUCCESS [ 0.033 s] [INFO] dubbo-serialization-avro ……………………… SUCCESS [ 0.016 s] [INFO] dubbo-serialization-gson ……………………… SUCCESS [ 0.016 s] [INFO] dubbo-serialization-protobuf ………………….. SUCCESS [ 0.241 s] [INFO] dubbo-serialization-test ……………………… SUCCESS [ 0.013 s] [INFO] dubbo-serialization-native-hession …………….. SUCCESS [ 0.015 s] [INFO] dubbo-dependencies-bom ……………………….. SUCCESS [ 0.173 s] [INFO] dubbo-bom …………………………………… SUCCESS [ 0.004 s] [INFO] dubbo-configcenter-apollo …………………….. SUCCESS [ 0.012 s] [INFO] dubbo-configcenter-etcd ………………………. SUCCESS [ 0.012 s] [INFO] dubbo-metadata-report-consul ………………….. SUCCESS [ 0.012 s] [INFO] dubbo-all …………………………………… SUCCESS [ 0.012 s] [INFO] dubbo-distribution …………………………… SUCCESS [ 0.005 s] [INFO] dubbo-dependencies-zookeeper ………………….. SUCCESS [ 0.005 s] [INFO] dubbo-dependencies …………………………… SUCCESS [ 0.004 s] [INFO] dubbo-metadata-definition-protobuf …………….. SUCCESS [ 0.014 s]

实例化

EnableDubbo

DubboComponentScanRegistrar

ServiceAnnotationBeanPostProcessor

ReferenceAnnotationBeanPostProcessor

EnableDubboConfig

DubboConfigConfigurationRegistrar