diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java index 357e1ad06..58bbec787 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java @@ -101,7 +101,7 @@ public class FlowExecutor { } // 规则缓存 - if (isStart && liteflowConfig.isRuleCacheEnabled()) { + if (isStart && liteflowConfig.getEnableRuleCache()) { Integer capacity = liteflowConfig.getRuleCacheCapacity(); RuleCacheLifeCycle ruleCacheLifeCycle = new RuleCacheLifeCycle(capacity); LifeCycleHolder.addLifeCycle(ruleCacheLifeCycle); 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 07cae7527..a13367421 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 @@ -113,6 +113,9 @@ public class LiteflowConfig { //是否启用节点实例ID private Boolean enableNodeInstanceId; + // 是否启用规则缓存 + private Boolean enableRuleCache; + // 规则缓存容量 private Integer ruleCacheCapacity; @@ -485,6 +488,16 @@ public class LiteflowConfig { this.enableNodeInstanceId = enableNodeInstanceId; } + public Boolean getEnableRuleCache() { + if (ObjectUtil.isNull(enableRuleCache)) { + return Boolean.FALSE; + } + return enableRuleCache; + } + + public void setEnableRuleCache(Boolean enableRuleCache) { + this.enableRuleCache = enableRuleCache; + } public Integer getRuleCacheCapacity() { return ruleCacheCapacity; @@ -493,8 +506,4 @@ public class LiteflowConfig { public void setRuleCacheCapacity(Integer ruleCacheCapacity) { this.ruleCacheCapacity = ruleCacheCapacity; } - - public boolean isRuleCacheEnabled() { - return ObjectUtil.isNotNull(ruleCacheCapacity) && ruleCacheCapacity > 0; - } } 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 6850a83ca..8b7cdc12e 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 @@ -99,6 +99,9 @@ public class LiteflowProperty { //是否启用节点实例ID private boolean enableNodeInstanceId; + // 是否启用规则缓存 + private Boolean enableRuleCache; + // 规则缓存容量 private Integer ruleCacheCapacity; @@ -341,4 +344,12 @@ public class LiteflowProperty { public void setRuleCacheCapacity(Integer ruleCacheCapacity) { this.ruleCacheCapacity = ruleCacheCapacity; } + + public Boolean isEnableRuleCache() { + return enableRuleCache; + } + + public void setEnableRuleCache(Boolean enableRuleCache) { + this.enableRuleCache = enableRuleCache; + } } 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 6668b1ef7..e4b9c4f50 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 @@ -53,6 +53,7 @@ public class LiteflowPropertyAutoConfiguration { liteflowConfig.setGlobalThreadPoolQueueSize(property.getGlobalThreadPoolQueueSize()); liteflowConfig.setGlobalThreadPoolSize(property.getGlobalThreadPoolSize()); liteflowConfig.setEnableNodeInstanceId(property.isEnableNodeInstanceId()); + liteflowConfig.setEnableRuleCache(property.isEnableRuleCache()); liteflowConfig.setRuleCacheCapacity(property.getRuleCacheCapacity()); 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 a68e2992a..89cb4d599 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 @@ -208,9 +208,16 @@ "defaultValue": false }, { - "name": "liteflow.liteflow.rule-cache-capacity", + "name": "liteflow.enable-rule-cache", + "type": "java.lang.Boolean", + "description": "Enable rule cache.", + "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty", + "defaultValue": false + }, + { + "name": "liteflow.rule-cache-capacity", "type": "java.lang.Integer", - "description": "Set the rules cache capacity.", + "description": "Set rule cache capacity.", "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty" } ] diff --git a/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties b/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties index 27b972e00..9a127bdc0 100644 --- a/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties +++ b/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties @@ -24,4 +24,5 @@ liteflow.global-thread-pool-size=16 liteflow.global-thread-pool-queue-size=512 liteflow.global-thread-pool-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultGlobalExecutorBuilder liteflow.enable-node-instance-id=false +liteflow.enable-rule-cache=false diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/ruleCache/application.properties b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/ruleCache/application.properties index 20fbd564f..069d7c7a1 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/ruleCache/application.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/ruleCache/application.properties @@ -1,2 +1,3 @@ liteflow.rule-source=ruleCache/flow.el.xml +liteflow.enable-rule-cache=true liteflow.rule-cache-capacity=3 \ No newline at end of file