update 代码重构

This commit is contained in:
Guoqs
2024-11-26 11:19:26 +08:00
parent e4f9182752
commit d0260eddc2
33 changed files with 291 additions and 199 deletions

View File

@@ -1,5 +1,7 @@
package com.jsowell.netty.factory;
import com.alibaba.fastjson2.JSON;
import com.jsowell.common.util.StringUtils;
import com.jsowell.netty.strategy.ykc.AbstractYkcStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -19,24 +21,26 @@ public class YKCOperateFactoryV2 {
private static Map<String, String> operationMap = new HashMap<>();
static {
//初始化实现类
operationMap.put("0x01", "loginRequestStrategy");
operationMap.put("0x05", "billingTemplateValidateRequestStrategy");
// more operators
}
// static {
// //初始化实现类
// operationMap.put("0x01", "loginRequestStrategy");
// operationMap.put("0x05", "billingTemplateValidateRequestStrategy");
// // more operators
// }
/**
* 注册
* @param str
* @param handler
* @param strategyName
*/
// public void register(String str, AbstractYkcHandlerV2 handler) {
// if (StringUtils.isBlank(str) || Objects.isNull(handler)) {
// return;
// }
// strategyMap.put(str, handler);
// }
public static void register(String str, String strategyName) {
if (StringUtils.isBlank(str) || StringUtils.isBlank(strategyName)) {
return;
}
// 获取首字母(类名首字母大写), 并将首字母变为小写
strategyName = strategyName.substring(0, 1).toLowerCase() + strategyName.substring(1);
operationMap.put(str, strategyName);
}
/**
* 获取
@@ -45,4 +49,8 @@ public class YKCOperateFactoryV2 {
String s = operationMap.get(frameType);
return strategyMap.get(s);
}
public static String getOperationMap() {
return JSON.toJSONString(operationMap);
}
}