Skip to content

Commit

Permalink
5.4 1.6小改动 马上开始netty版本了迫不及待
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzzzzzzyt committed May 4, 2022
1 parent 9c789b5 commit acf5706
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 33 deletions.
28 changes: 14 additions & 14 deletions zyt-rpc-call/src/main/java/service/bootstrap/ClientBootStrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import annotation.RpcClientBootStrap;

import consumer.bootstrap.nio.*;
import exception.RpcException;
import method.Customer;


import java.io.IOException;
Expand All @@ -11,7 +13,7 @@
//比如说这里的version 1.2 就是v1.2版本的启动器
@RpcClientBootStrap(version = "1.5")
public class ClientBootStrap {
public static void start() throws IOException{
public static Customer start() throws IOException, RpcException {
//获取当前的注解上的版本然后去调用相应的远端方法 反射的方法
//当前客户端启动器class对象
Class<ClientBootStrap> currentClientBootStrapClass = ClientBootStrap.class;
Expand All @@ -20,23 +22,21 @@ public static void start() throws IOException{
//根据注解获得的版本进行判断是哪个版本 然后进行启动
switch (currentVersion)
{
case "1.0":
NIOConsumerBootStrap10.main(null);
break;
case "1.1":
NIOConsumerBootStrap11.main(null);
break;
//1.2版本之前都是键盘输入 所以不是根据代理对象来进行调用的 暂时注释掉
// case "1.0":
// NIOConsumerBootStrap10.main(null);
// break;
// case "1.1":
// NIOConsumerBootStrap11.main(null);
// break;
case "1.2":
NIOConsumerBootStrap12.main(null);
break;
return NIOConsumerBootStrap12.main(null);
case "1.4":
NIOConsumerBootStrap14.main(null);
break;
return NIOConsumerBootStrap14.main(null);
case "1.5":
NIOConsumerBootStrap15.main(null);
break;
return NIOConsumerBootStrap15.main(null);
default:
System.out.println("太着急了兄弟,这个版本还没出呢!要不你给我提个PR");
throw new RpcException("太着急了兄弟,这个版本还没出呢!要不你给我提个PR");
}
}
}
10 changes: 8 additions & 2 deletions zyt-rpc-call/src/main/java/service/call/ClientCall.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package service.call;


import exception.RpcException;
import method.Customer;
import service.bootstrap.ClientBootStrap;

import java.io.IOException;

//通用启动类 将启动的逻辑藏在ClientBootStrap中
public class ClientCall {
public static void main(String[] args) throws IOException {
ClientBootStrap.start();
public static void main(String[] args) throws IOException, RpcException {
Customer customer = ClientBootStrap.start();
//实现调用
System.out.println(customer.Hello("success"));
System.out.println(customer.Bye("fail"));
System.out.println(customer.Hello("fail"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
以nio为网络编程框架的消费者端启动类
*/
public class NIOConsumerBootStrap12 {
public static void main(String[] args) throws IOException {
public static Customer main(String[] args) throws IOException {

RpcClientProxy clientProxy = new RpcClientProxy();
Customer customer = (Customer) clientProxy.getBean(Customer.class);
String response = customer.Hello("success");
System.out.println(response);
System.out.println(customer.Hello("fail"));
return (Customer) clientProxy.getBean(Customer.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@
以nio为网络编程框架的消费者端启动类 配合14的集体启动类
*/
public class NIOConsumerBootStrap14 {
public static void main(String[] args) throws IOException {
public static Customer main(String[] args) throws IOException {

RpcClientProxy clientProxy = new RpcClientProxy();
Customer customer = (Customer) clientProxy.getBean(Customer.class);
String response = customer.Hello("success");
System.out.println(response);
System.out.println(customer.Bye("fail"));
System.out.println(customer.Hello("fail"));
return (Customer) clientProxy.getBean(Customer.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
*/

public class NIOConsumerBootStrap15{
public static void main(String[] args) throws IOException {
public static Customer main(String[] args) throws IOException {

RpcClientProxy clientProxy = new RpcClientProxy();
Customer customer = (Customer) clientProxy.getBean(Customer.class);
String response = customer.Hello("success");
System.out.println(response);
System.out.println(customer.Bye("fail"));
System.out.println(customer.Hello("fail"));
return (Customer) clientProxy.getBean(Customer.class);

}
}
Binary file modified 手写RPC框架.pdf
Binary file not shown.

0 comments on commit acf5706

Please sign in to comment.