mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-13 06:15:51 +00:00
perf[module]: Event和protocol模块注释
This commit is contained in:
1 parent
e4d3945142
commit
036ba4885c
5 files changed
+35
-1
No files matched your search
@@ -31,6 +31,8 @@ import java.util.concurrent.ExecutorService;
|
||||
/**
|
||||
* @author jaysunxiao
|
||||
* @version 3.0
|
||||
* <p>
|
||||
* 在EventRegisterProcessor 中完成扫描
|
||||
*/
|
||||
public class EventContext implements ApplicationListener<ApplicationContextEvent>, Ordered {
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
/**
|
||||
* 这是一个后置处理器,在boot项目中注册EventContext时,会import导入EventRegisterProcessor这个组件,这是一个后置处理器,
|
||||
* 断点发现 在AbstractAutowireCapableBeanFactory或调用getBeanPostProcessors,这样子每一个后置处理器都会走postProcessAfterInitialization这个方法
|
||||
*
|
||||
* @author jaysunxiao
|
||||
* @version 3.0
|
||||
*/
|
||||
|
||||
@@ -33,9 +33,19 @@ public class ProtocolManager {
|
||||
public static final short MAX_PROTOCOL_NUM = Short.MAX_VALUE;
|
||||
public static final byte MAX_MODULE_NUM = Byte.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* 索引:协议号protocolId
|
||||
*/
|
||||
public static final IProtocolRegistration[] protocols = new IProtocolRegistration[MAX_PROTOCOL_NUM];
|
||||
/**
|
||||
* 索引:模块号
|
||||
*/
|
||||
public static final ProtocolModule[] modules = new ProtocolModule[MAX_MODULE_NUM];
|
||||
|
||||
/**
|
||||
* key:协议class
|
||||
* value:protocolId
|
||||
*/
|
||||
private static final Map<Class<?>, Short> protocolIdMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
@@ -68,12 +78,24 @@ public class ProtocolManager {
|
||||
return modules[protocols[id].module()];
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据模块id查找模块
|
||||
*
|
||||
* @param moduleId
|
||||
* @return
|
||||
*/
|
||||
public static ProtocolModule moduleByModuleId(byte moduleId) {
|
||||
var module = modules[moduleId];
|
||||
AssertionUtils.notNull(module, "[moduleId:{}]不存在", moduleId);
|
||||
return module;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据模块名字查找模块
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static ProtocolModule moduleByModuleName(String name) {
|
||||
var moduleOptional = Arrays.stream(modules)
|
||||
.filter(it -> Objects.nonNull(it))
|
||||
|
||||
@@ -47,7 +47,7 @@ public class GenerateOperation {
|
||||
private String protocolParam;
|
||||
|
||||
/**
|
||||
* 需要生成的协议文件
|
||||
* 需要生成的协议文件(c#、js、ts...等需要生成协议的语言都列出来)
|
||||
*/
|
||||
private final Set<CodeLanguage> generateLanguages = EnumSet.noneOf(CodeLanguage.class);
|
||||
|
||||
|
||||
@@ -58,6 +58,13 @@ public abstract class GenerateProtocolFile {
|
||||
index = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成各种语言的协议文件
|
||||
*
|
||||
* @param generateOperation
|
||||
* @throws IOException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public static void generate(GenerateOperation generateOperation) throws IOException, ClassNotFoundException {
|
||||
var protocols = ProtocolManager.protocols;
|
||||
|
||||
|
||||
Reference in new issue
Block a user