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 8b7cdc12e..bea2a0d4b 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 @@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.enums.ParseModeEnum; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -99,11 +100,33 @@ public class LiteflowProperty { //是否启用节点实例ID private boolean enableNodeInstanceId; - // 是否启用规则缓存 - private Boolean enableRuleCache; + // 规则缓存配置 + @NestedConfigurationProperty + private RuleCache ruleCache; - // 规则缓存容量 - private Integer ruleCacheCapacity; + public static class RuleCache { + // 是否启用规则缓存 + private Boolean enabled; + + // 规则缓存容量 + private Integer capacity; + + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public Integer getCapacity() { + return capacity; + } + + public void setCapacity(Integer capacity) { + this.capacity = capacity; + } + } public boolean isEnableMonitorFile() { return enableMonitorFile; @@ -337,19 +360,11 @@ public class LiteflowProperty { this.enableNodeInstanceId = enableNodeInstanceId; } - public Integer getRuleCacheCapacity() { - return ruleCacheCapacity; + public RuleCache getRuleCache() { + return ruleCache; } - public void setRuleCacheCapacity(Integer ruleCacheCapacity) { - this.ruleCacheCapacity = ruleCacheCapacity; - } - - public Boolean isEnableRuleCache() { - return enableRuleCache; - } - - public void setEnableRuleCache(Boolean enableRuleCache) { - this.enableRuleCache = enableRuleCache; + public void setRuleCache(RuleCache ruleCache) { + this.ruleCache = ruleCache; } } 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 e4b9c4f50..01b9e1afc 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,8 +53,8 @@ public class LiteflowPropertyAutoConfiguration { liteflowConfig.setGlobalThreadPoolQueueSize(property.getGlobalThreadPoolQueueSize()); liteflowConfig.setGlobalThreadPoolSize(property.getGlobalThreadPoolSize()); liteflowConfig.setEnableNodeInstanceId(property.isEnableNodeInstanceId()); - liteflowConfig.setEnableRuleCache(property.isEnableRuleCache()); - liteflowConfig.setRuleCacheCapacity(property.getRuleCacheCapacity()); + liteflowConfig.setEnableRuleCache(property.getRuleCache().getEnabled()); + liteflowConfig.setRuleCacheCapacity(property.getRuleCache().getCapacity()); 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 89cb4d599..615533078 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,14 +208,14 @@ "defaultValue": false }, { - "name": "liteflow.enable-rule-cache", + "name": "liteflow.rule-cache.enabled", "type": "java.lang.Boolean", "description": "Enable rule cache.", "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty", "defaultValue": false }, { - "name": "liteflow.rule-cache-capacity", + "name": "liteflow.rule-cache.capacity", "type": "java.lang.Integer", "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 9a127bdc0..0be2968a8 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,5 +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 +liteflow.rule-cache.enabled=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 36277b504..cb4066d3c 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,3 +1,3 @@ liteflow.rule-source=ruleCache/flow.el.xml -liteflow.enable-rule-cache=true -liteflow.rule-cache-capacity=5 \ No newline at end of file +liteflow.rule-cache.enabled=true +liteflow.rule-cache.capacity=5 \ No newline at end of file