当前位置: 首页 > news >正文

Dubbo之消费端服务RPC调用

在消费端服务是基于接口调用Provider端提供的服务,所以在消费端并没有服务公共接口的实现类。

  1. 使用过程中利用注解@DubboReference将目标接口作为某个类的字段属性,在解析该类时获取全部字段属性并单独关注解析存在注解@DubboReference的字段属性。
  2. 通过步骤1得到服务公共接口类型,在生成RootBeanDefinition时设置其Class属性为ReferenceBean,最终将服务公共接口注册至IOC容器中。
  3. 通过JdkDynamicAopProxy对服务公共接口生成代理。

ReferenceAnnotationBeanPostProcessor重置服务目标类在IOC注册表class的属性为ReferenceBean。

public class ReferenceBean<T> implements FactoryBean<T>{@Overridepublic T getObject() {if (lazyProxy == null) {// 对目标类代理处理createLazyProxy();}return (T) lazyProxy;}private void createLazyProxy() {ProxyFactory proxyFactory = new ProxyFactory();proxyFactory.setTargetSource(new DubboReferenceLazyInitTargetSource());proxyFactory.addInterface(interfaceClass);Class<?>[] internalInterfaces = AbstractProxyFactory.getInternalInterfaces();for (Class<?> anInterface : internalInterfaces) {proxyFactory.addInterface(anInterface);}if (!StringUtils.isEquals(interfaceClass.getName(), interfaceName)) {Class<?> serviceInterface = ClassUtils.forName(interfaceName, beanClassLoader);proxyFactory.addInterface(serviceInterface);}//jdk基于接口代理this.lazyProxy = proxyFactory.getProxy(this.beanClassLoader);}
}

http://www.lryc.cn/news/305298.html

相关文章:

  • 报表控件Stimulsoft 新版本2024.1中,功能区工具栏新功能
  • 零样本带解释性的医学大模型
  • 英文输入法(C 语言)
  • 万众一心 · 喜赢未来,2023宇凡微年会暨阳朔之旅
  • 【Spring】 AOP面向切面编程
  • R语言入门笔记2.6
  • PS人像处理磨皮插件
  • 类型转换(C++)
  • 2.23数据结构
  • c++笔记理解
  • 二进制部署k8s集群之cni网络插件
  • 二维矩阵子集的最大值
  • 瑞_23种设计模式_装饰者模式
  • 使用Python制作进度条有多少种方法?看这一篇文章就够了!
  • SpringBoot-2.7.6基于SLF4J日志门面的日志框架切换
  • MongoDB聚合运算符:$binarySize
  • Android的ViewModel
  • Android 圆环带刻度条进度动画效果实现
  • 94. 二叉树的中序遍历
  • 汽车信息安全概述
  • Linux——基础IO
  • 数据结构-数组
  • 【Java程序设计】【C00279】基于Springboot的智慧外贸平台(有论文)
  • C#,计算几何,计算机图形学(Computer Graphics)洪水填充算法(Flood Fill Algorithm)与源代码
  • C# 实现网页内容保存为图片并生成压缩包
  • C#_事件简述
  • C语言:指针(一)
  • 【leetcode刷题之路】面试经典150题(3)——哈希表+区间
  • 群晖NAS DSM7.2.1安装宝塔之后无法登陆账号密码问题解决
  • 9、使用 ChatGPT 的 GPT 制作自己的 GPT!