观看本篇博客,需要先看上篇:
https://jym12138.blog.csdn.net/article/details/104445084
服务引用流程
先看 DubboNamespaceHandler类的 init方法,在定义属性的时候有这样一行代码:
this.registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
ReferenceBean 继承ReferenceConfig 实现了 FactoryBean接口
FactoryBean接口:
通过 Object getObject() 注册进ioc容器 调用了get方法。
在get方法进行判断,如果ref为空,初始化 init方法。
在init方法中调用了:
this.ref = this.createProxy(map); 创建代理对象
createProxy方法调用了this.invoker = refprotocol.refer(this.interfaceClass, url);
RegistryProtocol refer 方法 —> doRefer 在doRefer 方法里调用了
directory.subscribe(subscribeUrl.addParameter("category", "providers,configurators,routers"));
这个方法的作用是订阅服务
DubboProtocol 的 refer方法,调用了:
DubboInvoker<T> invoker = new DubboInvoker(serviceType, url, this.getClients(url), this.invokers);
getClients 获取客户端 —> getSharedClient —> initClient 初始化客户端 创建netty客户端,去连接 将invoker返回
具体流程图:
学习年限不足,知识过浅,说的不对请见谅。
世界上有10种人,一种是懂二进制的,一种是不懂二进制的。
来源:CSDN
作者:jym12138
链接:https://blog.csdn.net/weixin_43326401/article/details/104447537