diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/NodeOperator.java b/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/NodeOperator.java index 2013b3b4e..007223126 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/NodeOperator.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/NodeOperator.java @@ -10,6 +10,7 @@ import com.ql.util.express.exception.QLException; import com.yomahub.liteflow.builder.el.operator.base.BaseOperator; import com.yomahub.liteflow.builder.el.operator.base.OperatorHelper; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.exception.ELParseException; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.element.FallbackNodeProxy; import com.yomahub.liteflow.flow.element.Node; @@ -26,7 +27,13 @@ public class NodeOperator extends BaseOperator { @Override public Node build(Object[] objects) throws Exception { - + // 检查是否开启了组件降级功能 + LiteflowConfig liteflowConfig = LiteflowConfigGetter.get(); + Boolean enable = liteflowConfig.getFallbackCmpEnable(); + if (!enable) { + throw new ELParseException("The fallback component is disabled"); + } + OperatorHelper.checkObjectSizeEqOne(objects); String nodeId = OperatorHelper.convert(objects[0], String.class); diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java b/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java index 814ccf49a..c0cbf0391 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java @@ -97,9 +97,6 @@ public class LiteflowConfig { // 是否打印执行中的日志 private Boolean printExecutionLog; - // 替补组件class路径 - private String substituteCmpClass; - // 规则文件/脚本文件变更监听 private Boolean enableMonitorFile = Boolean.FALSE; @@ -111,6 +108,9 @@ public class LiteflowConfig { //使用默认并行循环线程池时,最大队列数 private Integer parallelQueueLimit; + + // 是否启用组件降级 + private Boolean fallbackCmpEnable; public Boolean getEnableMonitorFile() { return enableMonitorFile; @@ -373,14 +373,6 @@ public class LiteflowConfig { this.printExecutionLog = printExecutionLog; } - public String getSubstituteCmpClass() { - return substituteCmpClass; - } - - public void setSubstituteCmpClass(String substituteCmpClass) { - this.substituteCmpClass = substituteCmpClass; - } - public String getRuleSourceExtData() { return ruleSourceExtData; } @@ -454,4 +446,16 @@ public class LiteflowConfig { public void setParallelLoopExecutorClass(String parallelLoopExecutorClass) { this.parallelLoopExecutorClass = parallelLoopExecutorClass; } + + public Boolean getFallbackCmpEnable() { + if (ObjectUtil.isNull(this.fallbackCmpEnable)) { + return false; + } else { + return fallbackCmpEnable; + } + } + + public void setFallbackCmpEnable(Boolean fallbackCmpEnable) { + this.fallbackCmpEnable = fallbackCmpEnable; + } } diff --git a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowAutoConfiguration.java b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowAutoConfiguration.java index 082f41ea5..f8ccebff6 100644 --- a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowAutoConfiguration.java +++ b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowAutoConfiguration.java @@ -46,10 +46,10 @@ public class LiteflowAutoConfiguration { liteflowConfig.setMainExecutorWorks(property.getMainExecutorWorks()); liteflowConfig.setMainExecutorClass(property.getMainExecutorClass()); liteflowConfig.setPrintExecutionLog(property.isPrintExecutionLog()); - liteflowConfig.setSubstituteCmpClass(property.getSubstituteCmpClass()); liteflowConfig.setParallelMaxWorkers(property.getParallelMaxWorkers()); liteflowConfig.setParallelQueueLimit(property.getParallelQueueLimit()); liteflowConfig.setParallelLoopExecutorClass(property.getParallelLoopExecutorClass()); + liteflowConfig.setFallbackCmpEnable(property.isFallbackCmpEnable()); return liteflowConfig; } diff --git a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowProperty.java b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowProperty.java index 2454ba472..6790bcd57 100644 --- a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowProperty.java +++ b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowProperty.java @@ -67,9 +67,6 @@ public class LiteflowProperty { // 是否打印执行过程中的日志 private boolean printExecutionLog; - // 替补组件的class路径 - private String substituteCmpClass; - //并行循环线程池类路径 private String parallelLoopExecutorClass; @@ -78,6 +75,9 @@ public class LiteflowProperty { //使用默认并行循环线程池时,最大队列数 private Integer parallelQueueLimit; + + // 是否启用组件降级 + private Boolean fallbackCmpEnable; public boolean isEnable() { return enable; @@ -212,14 +212,6 @@ public class LiteflowProperty { this.requestIdGeneratorClass = requestIdGeneratorClass; } - public String getSubstituteCmpClass() { - return substituteCmpClass; - } - - public void setSubstituteCmpClass(String substituteCmpClass) { - this.substituteCmpClass = substituteCmpClass; - } - public String getRuleSourceExtData() { return ruleSourceExtData; } @@ -251,4 +243,12 @@ public class LiteflowProperty { public void setParallelQueueLimit(Integer parallelQueueLimit) { this.parallelQueueLimit = parallelQueueLimit; } + + public Boolean isFallbackCmpEnable() { + return fallbackCmpEnable; + } + + public void setFallbackCmpEnable(Boolean fallbackCmpEnable) { + this.fallbackCmpEnable = fallbackCmpEnable; + } } diff --git a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowProperty.java b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowProperty.java index d13fdd402..2ac3b5dbb 100644 --- a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowProperty.java +++ b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowProperty.java @@ -74,9 +74,6 @@ public class LiteflowProperty { // 是否打印执行过程中的日志 private boolean printExecutionLog; - // 替补组件的class路径 - private String substituteCmpClass; - // 规则文件/脚本文件变更监听 private Boolean enableMonitorFile; @@ -87,6 +84,9 @@ public class LiteflowProperty { //使用默认并行循环线程池时,最大队列数 private Integer parallelQueueLimit; + + // 是否启用组件降级 + private Boolean fallbackCmpEnable; public Boolean getEnableMonitorFile() { return enableMonitorFile; @@ -226,14 +226,6 @@ public class LiteflowProperty { this.requestIdGeneratorClass = requestIdGeneratorClass; } - public String getSubstituteCmpClass() { - return substituteCmpClass; - } - - public void setSubstituteCmpClass(String substituteCmpClass) { - this.substituteCmpClass = substituteCmpClass; - } - public String getRuleSourceExtData() { return ruleSourceExtData; } @@ -289,4 +281,12 @@ public class LiteflowProperty { public void setParallelQueueLimit(Integer parallelQueueLimit) { this.parallelQueueLimit = parallelQueueLimit; } + + public Boolean isFallbackCmpEnable() { + return fallbackCmpEnable; + } + + public void setFallbackCmpEnable(Boolean fallbackCmpEnable) { + this.fallbackCmpEnable = fallbackCmpEnable; + } } diff --git a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/config/LiteflowPropertyAutoConfiguration.java b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/config/LiteflowPropertyAutoConfiguration.java index 39bf982b0..71c98bb1a 100644 --- a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/config/LiteflowPropertyAutoConfiguration.java +++ b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/config/LiteflowPropertyAutoConfiguration.java @@ -46,11 +46,11 @@ public class LiteflowPropertyAutoConfiguration { liteflowConfig.setMainExecutorWorks(property.getMainExecutorWorks()); liteflowConfig.setMainExecutorClass(property.getMainExecutorClass()); liteflowConfig.setPrintExecutionLog(property.isPrintExecutionLog()); - liteflowConfig.setSubstituteCmpClass(property.getSubstituteCmpClass()); liteflowConfig.setEnableMonitorFile(property.getEnableMonitorFile()); liteflowConfig.setParallelMaxWorkers(property.getParallelMaxWorkers()); liteflowConfig.setParallelQueueLimit(property.getParallelQueueLimit()); liteflowConfig.setParallelLoopExecutorClass(property.getParallelLoopExecutorClass()); + liteflowConfig.setFallbackCmpEnable(property.isFallbackCmpEnable()); return liteflowConfig; } diff --git a/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json index b6297cbee..a2fd62a47 100644 --- a/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -138,13 +138,6 @@ "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty", "defaultValue": true }, - { - "name": "liteflow.substitute-cmp-class", - "type": "java.lang.String", - "description": "substitute component class.", - "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty", - "defaultValue": "" - }, { "name": "liteflow.monitor.enable-log", "type": "java.lang.Boolean", @@ -200,6 +193,13 @@ "description": "Custom thread pool implement for parallel-loop executor.", "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty", "defaultValue": "com.yomahub.liteflow.thread.LiteFlowDefaultParallelLoopExecutorBuilder" + }, + { + "name": "liteflow.fallback-cmp-enable", + "type": "java.lang.Boolean", + "description": "Enable fallback component.", + "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty", + "defaultValue": false } ] } \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/fallback/application.properties b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/fallback/application.properties index 6e04fd049..b6a1da886 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/fallback/application.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/fallback/application.properties @@ -1 +1,2 @@ -liteflow.rule-source=fallback/flow.el.xml \ No newline at end of file +liteflow.rule-source=fallback/flow.el.xml +liteflow.fallback-cmp-enable=true \ No newline at end of file