Skip to content

一个简单的基于netty的RPC框架实现(demo)

Notifications You must be signed in to change notification settings

sijia3/rpc-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

原客户端访问接口方式:

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

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

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

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

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

About

一个简单的基于netty的RPC框架实现(demo)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages