项目作者: sijia3

项目描述 :
一个简单的基于netty的RPC框架实现(demo)
高级语言: Java
项目地址: git://github.com/sijia3/rpc-demo.git
创建时间: 2019-12-20T09:24:20Z
项目社区:https://github.com/sijia3/rpc-demo

开源协议:

下载


该项目基于黄勇-轻量级分布式 RPC 框架

在此基础上,将客户端的访问方式转换成类似于dubbo服务的访问。用户只需将服务(service)注册到xml中(自定义标签),即可通过直接注入方式(@Autowired)对service直接进行数据访问。

原客户端访问接口方式:

  1. ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
  2. RpcProxy rpcProxy = ctx.getBean(RpcProxy.class);
  3. HelloService helloService = rpcProxy.create(HelloService.class);
  4. String result = helloService.hello("World");
  5. System.out.println(result);

转换后的客户端访问接口方式:

  1. ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");
  2. HelloService helloService = ctx.getBean(HelloService.class);
  3. String str = helloService.hello("World"); // 直接使用,不需要create()创建
  4. System.out.println(str);

将rpcProxy.create()的工作交由spring管理,用户只需在xml里注册如下:

  1. <sijia3:service id="helloService" version="" class="com.sijia3.api.HelloService"></sijia3:service>