forked from zzzzzzzzyt/zeng-rpc-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a671bc7
commit 92ca01d
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
zyt-rpc-call/src/main/java/service/bootstrap/ServerBootStrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
13
zyt-rpc-common/src/main/java/annotation/RpcClientBootStrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
13
zyt-rpc-common/src/main/java/annotation/RpcServerBootStrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |