Skip to content

Commit

Permalink
4.30 1.3版本初版 继续完善
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzzzzzzyt committed Apr 30, 2022
1 parent a671bc7 commit 92ca01d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
35 changes: 35 additions & 0 deletions zyt-rpc-call/src/main/java/service/bootstrap/ServerBootStrap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package service.bootstrap;

import annotation.RpcServerBootStrap;
import org.apache.zookeeper.KeeperException;
import provider.bootstrap.NIOProviderBootStrap10;
import provider.bootstrap.NIOProviderBootStrap11;
import provider.bootstrap.NIOProviderBootStrap12;

import java.io.IOException;

//之后启动直接在这边启动根据 在注解中配置对应的版本号 将相应的操作封装到之后的操作中即可
//比如说这里的version 1.2 就是v1.2版本的启动器
@RpcServerBootStrap(version = "1.5")
public class ServerBootStrap {
public static void start() throws IOException, InterruptedException, KeeperException {
Class<ServerBootStrap> serverBootStrapClass = ServerBootStrap.class;
RpcServerBootStrap annotation = serverBootStrapClass.getAnnotation(RpcServerBootStrap.class);
//当前服务端启动器 class对象
String currentServerBootStrapVersion = annotation.version();
switch (currentServerBootStrapVersion)
{
case "1.0":
NIOProviderBootStrap10.main(null);
break;
case "1.1":
NIOProviderBootStrap11.main(null);
break;
case "1.2":
NIOProviderBootStrap12.main(null);
break;
default:
System.out.println("太着急了兄弟,这个版本还没出呢!要不你给我提个PR");
}
}
}
14 changes: 14 additions & 0 deletions zyt-rpc-call/src/main/java/service/call/ServerCall.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package service.call;


import org.apache.zookeeper.KeeperException;
import service.bootstrap.ServerBootStrap;

import java.io.IOException;

//通用启动类 将启动的逻辑藏在ServerBootStrap中
public class ServerCall {
public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
ServerBootStrap.start();
}
}
13 changes: 13 additions & 0 deletions zyt-rpc-common/src/main/java/annotation/RpcClientBootStrap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

//注解 通过此注解可以判断当前是哪一个版本 选择调用哪个版本的客户端启动器
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface RpcClientBootStrap {
String version();
}
13 changes: 13 additions & 0 deletions zyt-rpc-common/src/main/java/annotation/RpcServerBootStrap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

//注解 通过此注解可以判断当前是哪一个版本 选择调用哪个版本的服务端启动器
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface RpcServerBootStrap {
String version();
}

0 comments on commit 92ca01d

Please sign in to comment.