mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-15 20:42:09 +08:00
添加XML Parser
This commit is contained in:
@@ -1,4 +1,64 @@
|
||||
package com.yomahub.liteflow.parser.redis;
|
||||
|
||||
public class RedisXmlELParser {
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.StrFormatter;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.parser.el.ClassXmlFlowELParser;
|
||||
import com.yomahub.liteflow.parser.redis.exception.RedisException;
|
||||
import com.yomahub.liteflow.parser.redis.vo.RedisParserVO;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.util.JsonUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class RedisXmlELParser extends ClassXmlFlowELParser {
|
||||
|
||||
private static final String ERROR_COMMON_MSG = "ruleSourceExtData or map is empty";
|
||||
|
||||
private static final String ERROR_MSG_PATTERN = "uleSourceExtData {} is blank";
|
||||
|
||||
public RedisXmlELParser() {
|
||||
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
|
||||
|
||||
try{
|
||||
RedisParserVO redisParserVO = null;
|
||||
if (MapUtil.isNotEmpty((liteflowConfig.getRuleSourceExtDataMap()))) {
|
||||
redisParserVO = BeanUtil.toBean(liteflowConfig.getRuleSourceExtDataMap(),
|
||||
RedisParserVO.class, CopyOptions.create());
|
||||
}
|
||||
else if (StrUtil.isNotBlank(liteflowConfig.getRuleSourceExtData())) {
|
||||
redisParserVO = JsonUtil.parseObject(liteflowConfig.getRuleSourceExtData(), RedisParserVO.class);
|
||||
}
|
||||
if (Objects.isNull(redisParserVO)) {
|
||||
throw new RedisException(ERROR_COMMON_MSG);
|
||||
}
|
||||
|
||||
//检查配置文件
|
||||
checkParserVO(redisParserVO);
|
||||
}
|
||||
catch (RedisException redisException){
|
||||
throw redisException;
|
||||
}
|
||||
catch (Exception e){
|
||||
throw new RedisException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parseCustom() {
|
||||
//todo
|
||||
return null;
|
||||
}
|
||||
|
||||
private void checkParserVO(RedisParserVO redisParserVO) {
|
||||
if (StrUtil.isEmpty(redisParserVO.getHost())){
|
||||
throw new RedisException(StrFormatter.format(ERROR_MSG_PATTERN, "host"));
|
||||
}
|
||||
if (StrUtil.isEmpty(redisParserVO.getPort())){
|
||||
throw new RedisException(StrFormatter.format(ERROR_MSG_PATTERN, "port"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
package com.yomahub.liteflow.parser.redis.exception;
|
||||
|
||||
public class RedisException {
|
||||
public class RedisException extends RuntimeException{
|
||||
|
||||
private String message;
|
||||
|
||||
public RedisException(String message) {
|
||||
super();
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
package com.yomahub.liteflow.parser.redis.util;
|
||||
|
||||
import com.yomahub.liteflow.parser.redis.vo.RedisParserVO;
|
||||
|
||||
public class RedisParserHelper {
|
||||
|
||||
private RedisParserVO redisParserVO;
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.yomahub.liteflow.parser.redis.vo;
|
||||
public class RedisParserVO {
|
||||
|
||||
/*连接地址*/
|
||||
private String url;
|
||||
private String host;
|
||||
|
||||
/*端口号*/
|
||||
private String port;
|
||||
@@ -15,9 +15,9 @@ public class RedisParserVO {
|
||||
private String password;
|
||||
|
||||
/*是否采用轮询机制 默认为轮询 否则选择pub/sub机制*/
|
||||
private boolean isPolling = true;
|
||||
private String isPolling = "true";
|
||||
|
||||
/*轮询时间间隔(ms) 默认1分组 若选择pub/sub机制可不配置*/
|
||||
/*轮询时间间隔(ms) 默认1分钟 若选择pub/sub机制可不配置*/
|
||||
private String pollingInterval = "60000";
|
||||
|
||||
/*chain表配置的数据库号*/
|
||||
@@ -32,12 +32,12 @@ public class RedisParserVO {
|
||||
/*脚本配置的键名*/
|
||||
private String scriptKey;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
public void setHost(String url) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
@@ -64,11 +64,11 @@ public class RedisParserVO {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public boolean isPolling() {
|
||||
public String isPolling() {
|
||||
return isPolling;
|
||||
}
|
||||
|
||||
public void setPolling(boolean polling) {
|
||||
public void setPolling(String polling) {
|
||||
isPolling = polling;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user