From 3eb987d0b0d1d02dae2cdc639f6ecd4e4180c8b0 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Wed, 18 Jan 2023 17:51:20 +0800 Subject: [PATCH 01/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96=20=20=20=20=20=20-=20=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E8=84=9A=E6=9C=AC=E5=8F=98=E9=87=8F=E5=A4=84?= =?UTF-8?q?=E7=90=86=20=20=20=20=20=20-=20=E5=BC=95=E6=93=8E=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 3 +- smart-flow-core/pom.xml | 2 +- .../org/smartboot/flow/core/FlowEngine.java | 17 ++++++ .../flow/core/script/ScriptCondition.java | 14 +++++ .../flow/core/script/ScriptConstants.java | 7 +++ .../core/script/ScriptVariableManager.java | 60 +++++++++++++++++++ smart-flow-helper/pom.xml | 27 +++++++++ .../helper}/useful/AbstractEngineQuery.java | 2 +- .../useful/AbstractExecutorSelector.java | 2 +- .../helper}/useful/DefaultEngineQuery.java | 2 +- .../useful/DefaultExecutorSelector.java | 2 +- .../helper}/useful/EngineExecutorManager.java | 2 +- .../flow/helper}/useful/ExecutorSelector.java | 2 +- smart-flow-manager/pom.xml | 13 +--- smart-flow-script-condition/pom.xml | 4 +- .../smart-flow-script-groovy/pom.xml | 2 +- .../groovy/GroovyScriptCondition.java | 7 +++ .../smart-flow-script-ognl/pom.xml | 2 +- .../extension/ognl/OgnlScriptCondition.java | 6 ++ .../smart-flow-script-qlexpress/pom.xml | 2 +- .../qlexpress/QlExpressScriptCondition.java | 8 +++ smart-flow-spring-extension/pom.xml | 40 ++----------- smart-flow-springboot-starter/pom.xml | 9 +-- 23 files changed, 169 insertions(+), 66 deletions(-) create mode 100644 smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptVariableManager.java create mode 100644 smart-flow-helper/pom.xml rename {smart-flow-core/src/main/java/org/smartboot/flow/core => smart-flow-helper/src/main/java/org/smartboot/flow/helper}/useful/AbstractEngineQuery.java (90%) rename {smart-flow-core/src/main/java/org/smartboot/flow/core => smart-flow-helper/src/main/java/org/smartboot/flow/helper}/useful/AbstractExecutorSelector.java (96%) rename {smart-flow-core/src/main/java/org/smartboot/flow/core => smart-flow-helper/src/main/java/org/smartboot/flow/helper}/useful/DefaultEngineQuery.java (91%) rename {smart-flow-core/src/main/java/org/smartboot/flow/core => smart-flow-helper/src/main/java/org/smartboot/flow/helper}/useful/DefaultExecutorSelector.java (93%) rename {smart-flow-core/src/main/java/org/smartboot/flow/core => smart-flow-helper/src/main/java/org/smartboot/flow/helper}/useful/EngineExecutorManager.java (98%) rename {smart-flow-core/src/main/java/org/smartboot/flow/core => smart-flow-helper/src/main/java/org/smartboot/flow/helper}/useful/ExecutorSelector.java (92%) diff --git a/pom.xml b/pom.xml index 72fef30..a73fe4f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.smartboot.flow smart-flow-parent - 1.0.4 + 1.0.5-SNAPSHOT 4.0.0 pom smart-flow @@ -17,6 +17,7 @@ smart-flow-manager smart-flow-script-condition smart-flow-springboot-starter + smart-flow-helper https://gitee.com/smartboot/smart-flow diff --git a/smart-flow-core/pom.xml b/smart-flow-core/pom.xml index 9cfc49b..98bd2ce 100644 --- a/smart-flow-core/pom.xml +++ b/smart-flow-core/pom.xml @@ -5,7 +5,7 @@ org.smartboot.flow smart-flow-parent - 1.0.4 + 1.0.5-SNAPSHOT 4.0.0 diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java index 6b2e71b..3c0958f 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java @@ -25,6 +25,13 @@ public class FlowEngine implements Describable, Validator, Measurable { private String name; private volatile boolean validateCalled = false; + /** + * Start timestamp + * + * @since 1.0.5 + */ + private final long startedAt = System.currentTimeMillis(); + /* Used in async invoking */ private ExecutorService executor; @@ -129,6 +136,16 @@ public class FlowEngine implements Describable, Validator, Measurable { this.executor = executor; } + /** + * Return flow-engine created timestamp. + * + * @return timestamp + * @since 1.0.5 + */ + public long getStartedAt() { + return startedAt; + } + @Override public String describe() { return "flow-engine##" + name; diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptCondition.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptCondition.java index 8ef1d8b..5ebe2ec 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptCondition.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptCondition.java @@ -3,6 +3,8 @@ package org.smartboot.flow.core.script; import org.smartboot.flow.core.EngineContext; import org.smartboot.flow.core.NamedCondition; +import java.util.Map; + /** * @author qinluo * @date 2022/11/28 19:41 @@ -41,6 +43,18 @@ public abstract class ScriptCondition extends NamedCondition { @Override public abstract Object test(EngineContext context); + /** + * 允许用户在脚本上下文中绑定自定义的变量,用于执行脚本。 + * 其中key为脚本中用到的变量名,内置变量名参考 {@link org.smartboot.flow.core.script.ScriptConstants} + * + * @since 1.0.5 + * @param context engine ctx. + * @return bound keys. + */ + protected Map bindCustomized(EngineContext context) { + return ScriptVariableManager.getRegistered(context.getEngineName()); + } + @Override public String describe() { return "script-" + getType() + "-" + super.describe(); diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptConstants.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptConstants.java index 8d20f40..0122203 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptConstants.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptConstants.java @@ -23,4 +23,11 @@ public interface ScriptConstants { * Flow engine execution context. */ String CONTEXT = "context"; + + /** + * Alias for context. + * + * @since 1.0.5 + */ + String CTX = "ctx"; } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptVariableManager.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptVariableManager.java new file mode 100644 index 0000000..d6199cb --- /dev/null +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptVariableManager.java @@ -0,0 +1,60 @@ +package org.smartboot.flow.core.script; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + *

+ * 1、提供全局脚本变量注册 + * 2、提供基于引擎维度的脚本变量注册 + *

+ * + * @author qinluo + * @date 2023-01-17 19:41 + * @since 1.0.5 + */ +public class ScriptVariableManager { + + /** + * 全局脚本变量注册 + */ + private static final Map GLOBAL = new ConcurrentHashMap<>(); + + /** + * 引擎维度脚本变量注册 + */ + private static final Map> ENGINE_VARIABLES = new ConcurrentHashMap<>(); + + public static void register(String key, Object variable) { + GLOBAL.put(key, variable); + } + + public static Object remove(String key) { + return GLOBAL.remove(key); + } + + public synchronized static void register(String engine, String key, Object variable) { + Map variables = ENGINE_VARIABLES.getOrDefault(engine, new ConcurrentHashMap<>()); + variables.put(key, variable); + ENGINE_VARIABLES.put(engine, variables); + } + + public static Object remove(String engine, String key) { + Map variables = ENGINE_VARIABLES.get(engine); + if (variables != null) { + return variables.remove(key); + } + + return null; + } + + public static Map getRegistered(String engine) { + Map allRegistered = new HashMap<>(GLOBAL); + Map variables = ENGINE_VARIABLES.get(engine); + if (variables != null) { + allRegistered.putAll(variables); + } + return allRegistered; + } +} diff --git a/smart-flow-helper/pom.xml b/smart-flow-helper/pom.xml new file mode 100644 index 0000000..3653215 --- /dev/null +++ b/smart-flow-helper/pom.xml @@ -0,0 +1,27 @@ + + + + smart-flow-parent + org.smartboot.flow + 1.0.5-SNAPSHOT + + 4.0.0 + + smart-flow-helper + + + 8 + 8 + + + + + org.smartboot.flow + smart-flow-core + 1.0.5-SNAPSHOT + + + + \ No newline at end of file diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/useful/AbstractEngineQuery.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/AbstractEngineQuery.java similarity index 90% rename from smart-flow-core/src/main/java/org/smartboot/flow/core/useful/AbstractEngineQuery.java rename to smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/AbstractEngineQuery.java index b7bdbd6..bbf1645 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/useful/AbstractEngineQuery.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/AbstractEngineQuery.java @@ -1,4 +1,4 @@ -package org.smartboot.flow.core.useful; +package org.smartboot.flow.helper.useful; import java.io.Serializable; diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/useful/AbstractExecutorSelector.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/AbstractExecutorSelector.java similarity index 96% rename from smart-flow-core/src/main/java/org/smartboot/flow/core/useful/AbstractExecutorSelector.java rename to smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/AbstractExecutorSelector.java index eae0904..857824e 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/useful/AbstractExecutorSelector.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/AbstractExecutorSelector.java @@ -1,4 +1,4 @@ -package org.smartboot.flow.core.useful; +package org.smartboot.flow.helper.useful; import org.smartboot.flow.core.FlowEngine; diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/useful/DefaultEngineQuery.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/DefaultEngineQuery.java similarity index 91% rename from smart-flow-core/src/main/java/org/smartboot/flow/core/useful/DefaultEngineQuery.java rename to smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/DefaultEngineQuery.java index 4c9cca2..9e382e1 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/useful/DefaultEngineQuery.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/DefaultEngineQuery.java @@ -1,4 +1,4 @@ -package org.smartboot.flow.core.useful; +package org.smartboot.flow.helper.useful; /** * 通过engineName查询engine diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/useful/DefaultExecutorSelector.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/DefaultExecutorSelector.java similarity index 93% rename from smart-flow-core/src/main/java/org/smartboot/flow/core/useful/DefaultExecutorSelector.java rename to smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/DefaultExecutorSelector.java index db681dc..0b1c2e2 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/useful/DefaultExecutorSelector.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/DefaultExecutorSelector.java @@ -1,4 +1,4 @@ -package org.smartboot.flow.core.useful; +package org.smartboot.flow.helper.useful; import org.smartboot.flow.core.FlowEngine; diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/useful/EngineExecutorManager.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/EngineExecutorManager.java similarity index 98% rename from smart-flow-core/src/main/java/org/smartboot/flow/core/useful/EngineExecutorManager.java rename to smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/EngineExecutorManager.java index 4a26934..4ee6b0b 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/useful/EngineExecutorManager.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/EngineExecutorManager.java @@ -1,4 +1,4 @@ -package org.smartboot.flow.core.useful; +package org.smartboot.flow.helper.useful; diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/useful/ExecutorSelector.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/ExecutorSelector.java similarity index 92% rename from smart-flow-core/src/main/java/org/smartboot/flow/core/useful/ExecutorSelector.java rename to smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/ExecutorSelector.java index 7236ff8..7415f40 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/useful/ExecutorSelector.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/useful/ExecutorSelector.java @@ -1,4 +1,4 @@ -package org.smartboot.flow.core.useful; +package org.smartboot.flow.helper.useful; import org.smartboot.flow.core.FlowEngine; diff --git a/smart-flow-manager/pom.xml b/smart-flow-manager/pom.xml index 307564e..89b2328 100644 --- a/smart-flow-manager/pom.xml +++ b/smart-flow-manager/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.4 + 1.0.5-SNAPSHOT 4.0.0 @@ -20,14 +20,7 @@ org.smartboot.flow smart-flow-core - 1.0.4 - - - - org.smartboot.flow - smart-flow-spring-extension - 1.0.4 - true + 1.0.5-SNAPSHOT @@ -39,7 +32,7 @@ com.alibaba fastjson - 2.0.20.graal + 2.0.22 diff --git a/smart-flow-script-condition/pom.xml b/smart-flow-script-condition/pom.xml index 210a90a..84b170b 100644 --- a/smart-flow-script-condition/pom.xml +++ b/smart-flow-script-condition/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.4 + 1.0.5-SNAPSHOT 4.0.0 pom @@ -27,7 +27,7 @@ org.smartboot.flow smart-flow-core - 1.0.4 + 1.0.5-SNAPSHOT diff --git a/smart-flow-script-condition/smart-flow-script-groovy/pom.xml b/smart-flow-script-condition/smart-flow-script-groovy/pom.xml index 572064d..f2a16f6 100644 --- a/smart-flow-script-condition/smart-flow-script-groovy/pom.xml +++ b/smart-flow-script-condition/smart-flow-script-groovy/pom.xml @@ -5,7 +5,7 @@ smart-flow-script-condition org.smartboot.flow - 1.0.4 + 1.0.5-SNAPSHOT 4.0.0 diff --git a/smart-flow-script-condition/smart-flow-script-groovy/src/main/java/org/smartboot/flow/condition/extension/groovy/GroovyScriptCondition.java b/smart-flow-script-condition/smart-flow-script-groovy/src/main/java/org/smartboot/flow/condition/extension/groovy/GroovyScriptCondition.java index b464d08..83d2cfd 100644 --- a/smart-flow-script-condition/smart-flow-script-groovy/src/main/java/org/smartboot/flow/condition/extension/groovy/GroovyScriptCondition.java +++ b/smart-flow-script-condition/smart-flow-script-groovy/src/main/java/org/smartboot/flow/condition/extension/groovy/GroovyScriptCondition.java @@ -10,6 +10,7 @@ import org.smartboot.flow.core.script.ScriptConstants; import javax.script.Bindings; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; +import java.util.Map; /** * @author qinluo @@ -33,6 +34,12 @@ public class GroovyScriptCondition extends ScriptCondition { data.put(ScriptConstants.REQ, engineContext.getReq()); data.put(ScriptConstants.RESULT, engineContext.getResult()); data.put(ScriptConstants.CONTEXT, engineContext); + data.put(ScriptConstants.CTX, engineContext); + + Map variables = super.bindCustomized(engineContext); + if (variables != null) { + data.putAll(variables); + } Object value = engine.eval(script, data); if (LOGGER.isDebugEnabled()) { diff --git a/smart-flow-script-condition/smart-flow-script-ognl/pom.xml b/smart-flow-script-condition/smart-flow-script-ognl/pom.xml index 139a2ea..94d83ab 100644 --- a/smart-flow-script-condition/smart-flow-script-ognl/pom.xml +++ b/smart-flow-script-condition/smart-flow-script-ognl/pom.xml @@ -5,7 +5,7 @@ smart-flow-script-condition org.smartboot.flow - 1.0.4 + 1.0.5-SNAPSHOT 4.0.0 diff --git a/smart-flow-script-condition/smart-flow-script-ognl/src/main/java/org/smartboot/flow/condition/extension/ognl/OgnlScriptCondition.java b/smart-flow-script-condition/smart-flow-script-ognl/src/main/java/org/smartboot/flow/condition/extension/ognl/OgnlScriptCondition.java index e930fcc..bf70ddb 100644 --- a/smart-flow-script-condition/smart-flow-script-ognl/src/main/java/org/smartboot/flow/condition/extension/ognl/OgnlScriptCondition.java +++ b/smart-flow-script-condition/smart-flow-script-ognl/src/main/java/org/smartboot/flow/condition/extension/ognl/OgnlScriptCondition.java @@ -27,6 +27,12 @@ public class OgnlScriptCondition extends ScriptCondition { context.put(ScriptConstants.REQ, engineContext.getReq()); context.put(ScriptConstants.RESULT, engineContext.getResult()); context.put(ScriptConstants.CONTEXT, engineContext); + context.put(ScriptConstants.CTX, engineContext); + + Map variables = super.bindCustomized(engineContext); + if (variables != null) { + context.putAll(variables); + } Object value = Ognl.getValue(script, context); if (LOGGER.isDebugEnabled()) { diff --git a/smart-flow-script-condition/smart-flow-script-qlexpress/pom.xml b/smart-flow-script-condition/smart-flow-script-qlexpress/pom.xml index 2aec95a..cbca1b6 100644 --- a/smart-flow-script-condition/smart-flow-script-qlexpress/pom.xml +++ b/smart-flow-script-condition/smart-flow-script-qlexpress/pom.xml @@ -5,7 +5,7 @@ smart-flow-script-condition org.smartboot.flow - 1.0.4 + 1.0.5-SNAPSHOT 4.0.0 diff --git a/smart-flow-script-condition/smart-flow-script-qlexpress/src/main/java/org/smartboot/flow/condition/extension/qlexpress/QlExpressScriptCondition.java b/smart-flow-script-condition/smart-flow-script-qlexpress/src/main/java/org/smartboot/flow/condition/extension/qlexpress/QlExpressScriptCondition.java index 4623cc4..a3bff74 100644 --- a/smart-flow-script-condition/smart-flow-script-qlexpress/src/main/java/org/smartboot/flow/condition/extension/qlexpress/QlExpressScriptCondition.java +++ b/smart-flow-script-condition/smart-flow-script-qlexpress/src/main/java/org/smartboot/flow/condition/extension/qlexpress/QlExpressScriptCondition.java @@ -9,6 +9,8 @@ import org.smartboot.flow.core.exception.FlowException; import org.smartboot.flow.core.script.ScriptCondition; import org.smartboot.flow.core.script.ScriptConstants; +import java.util.Map; + /** * @author qinluo * @date 2022/11/29 21:01 @@ -26,6 +28,12 @@ public class QlExpressScriptCondition extends ScriptCondition { qlContext.put(ScriptConstants.REQ, engineContext.getReq()); qlContext.put(ScriptConstants.RESULT, engineContext.getResult()); qlContext.put(ScriptConstants.CONTEXT, engineContext); + qlContext.put(ScriptConstants.CTX, engineContext); + + Map variables = super.bindCustomized(engineContext); + if (variables != null) { + qlContext.putAll(variables); + } ExpressRunner runner = new ExpressRunner(); Object value = runner.execute(script, qlContext, null, true, false); diff --git a/smart-flow-spring-extension/pom.xml b/smart-flow-spring-extension/pom.xml index ceef2f0..0d06ca6 100644 --- a/smart-flow-spring-extension/pom.xml +++ b/smart-flow-spring-extension/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.4 + 1.0.5-SNAPSHOT 4.0.0 @@ -18,10 +18,11 @@ + org.smartboot.flow - smart-flow-core - 1.0.4 + smart-flow-manager + 1.0.5-SNAPSHOT @@ -37,43 +38,10 @@ ${spring.version} - - org.springframework - spring-orm - ${spring.version} - - - - org.springframework - spring-aop - ${spring.version} - - org.springframework spring-beans ${spring.version} - - org.springframework - spring-test - 5.2.4.RELEASE - test - - - - - org.junit.jupiter - junit-jupiter-api - 5.9.1 - test - - - - org.junit.jupiter - junit-jupiter-engine - 5.9.1 - test - \ No newline at end of file diff --git a/smart-flow-springboot-starter/pom.xml b/smart-flow-springboot-starter/pom.xml index aa357a5..365a1c6 100644 --- a/smart-flow-springboot-starter/pom.xml +++ b/smart-flow-springboot-starter/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.4 + 1.0.5-SNAPSHOT 4.0.0 @@ -25,12 +25,7 @@ org.smartboot.flow smart-flow-spring-extension - 1.0.4 - - - org.smartboot.flow - smart-flow-manager - 1.0.4 + 1.0.5-SNAPSHOT -- Gitee From 80b99d1267e067557135ffe3daf210a409e2a9df Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Fri, 27 Jan 2023 12:42:41 +0800 Subject: [PATCH 02/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20ObjectCreato?= =?UTF-8?q?r=E6=94=B9=E9=80=A0=20=20=20=20=20=20-=20FakeObjectCreator?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attribute/AttributeValueResolver.java | 2 +- .../core/parser/BuilderDefinitionVisitor.java | 30 +++++++--------- .../core/parser/DefaultObjectCreator.java | 2 +- .../flow/core/parser/ObjectCreator.java | 10 +++--- .../flow/helper/mock/FakeAdapter.java | 36 +++++++++++++++++++ .../flow/helper/mock/FakeCondition.java | 24 +++++++++++++ .../flow/helper/mock/FakeExecutable.java | 24 +++++++++++++ .../flow/helper/mock/FakeObjectCreator.java | 18 ++++++++++ .../flow/helper/mock/FakeScriptCondition.java | 36 +++++++++++++++++++ .../spring/extension/SpringObjectCreator.java | 4 +-- 10 files changed, 160 insertions(+), 26 deletions(-) create mode 100644 smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeAdapter.java create mode 100644 smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeCondition.java create mode 100644 smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeExecutable.java create mode 100644 smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeObjectCreator.java create mode 100644 smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeScriptCondition.java diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/AttributeValueResolver.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/AttributeValueResolver.java index 9c53a80..368a153 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/AttributeValueResolver.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/AttributeValueResolver.java @@ -100,7 +100,7 @@ public class AttributeValueResolver { // for classname. try { - return objectCreator.create(strValue, true); + return objectCreator.create(strValue, null,true); } catch (Exception ignored) { // Maybe not a class. } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/BuilderDefinitionVisitor.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/BuilderDefinitionVisitor.java index 1ee33c1..6fbbd40 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/BuilderDefinitionVisitor.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/BuilderDefinitionVisitor.java @@ -61,9 +61,9 @@ public class BuilderDefinitionVisitor implements DefinitionVisitor { Class javaType = sed.getJavaType(); ScriptCondition condition; if (javaType != null) { - condition = objectCreator.create(javaType.getName(), true); + condition = objectCreator.create(javaType.getName(), ScriptCondition.class, true); } else { - condition = objectCreator.create(sed.getType(), true); + condition = objectCreator.create(sed.getType(), ScriptCondition.class, true); } condition.setName(sed.getName()); @@ -155,16 +155,12 @@ public class BuilderDefinitionVisitor implements DefinitionVisitor { // resolve value type. builder.apply(p.getAttribute(), p.getValue()); }); - Component component = builder.newAdapter((Executable) newInstance(ed.getExecute())); + Component component = builder.newAdapter(newInstance(ed.getExecute(), Executable.class)); namedComponents.put(ed.getIdentifier(), component); } - private Object newInstance(String type) { - try { - return objectCreator.create(type, useCache); - } catch (Exception e) { - throw new IllegalStateException(type, e); - } + private T newInstance(String type, Class expectType) { + return objectCreator.create(type, expectType, useCache); } @Override @@ -172,11 +168,11 @@ public class BuilderDefinitionVisitor implements DefinitionVisitor { String test = ed.getTest(); Condition condition; if (AuxiliaryUtils.isType(test)) { - condition = (Condition) newInstance(test); + condition = newInstance(test, Condition.class); } else if (ed.getContext().getRegistered(test) != null) { condition = getInternalObject(test, ed.getContext()); } else { - condition = (Condition) newInstance(test); + condition = newInstance(test, Condition.class); } AssertUtil.notNull(condition, "can't find condition for if-element, test = " + test); @@ -212,11 +208,11 @@ public class BuilderDefinitionVisitor implements DefinitionVisitor { String test = ed.getTest(); Condition condition; if (AuxiliaryUtils.isType(test)) { - condition = (Condition) newInstance(test); + condition = newInstance(test, Condition.class); } else if (ed.getContext().getRegistered(test) != null) { condition = getInternalObject(test, ed.getContext()); } else { - condition = (Condition) newInstance(test); + condition = newInstance(test, Condition.class); } AssertUtil.notNull(condition, "can't find condition for choose-element, test = " + test); @@ -254,18 +250,16 @@ public class BuilderDefinitionVisitor implements DefinitionVisitor { @Override public void visit(AdapterDefinition ed) { String execute = ed.getExecute(); - Object adapter; + Adapter adapter = null; if (AuxiliaryUtils.isType(execute)) { - adapter = newInstance(execute); - } else { - adapter = ed.getContext().getRegistered(execute); + adapter = newInstance(execute, Adapter.class); } AssertUtil.notNull(adapter, "can't find adapter , execute=" + execute); ed.getPipelineElement().visit(this); Component component = namedComponents.get(ed.getPipelineElement().getIdentifier()); - AdapterBuilder adapterBuilder = new AdapterBuilder((Adapter) adapter, component); + AdapterBuilder adapterBuilder = new AdapterBuilder(adapter, component); ed.getAttributes().forEach(p -> { // resolve value type. adapterBuilder.apply(p.getAttribute(), p.getValue()); diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/DefaultObjectCreator.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/DefaultObjectCreator.java index 66df9a7..e5247d1 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/DefaultObjectCreator.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/DefaultObjectCreator.java @@ -30,7 +30,7 @@ public class DefaultObjectCreator implements ObjectCreator { } @Override - public T create(String typename, boolean useCache) { + public T create(String typename, Class expectType, boolean useCache) { AssertUtil.notBlank(typename, "type must not be blank!"); Class type = check(typename); AssertUtil.notNull(type, "typename " + typename + " is not class"); diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/ObjectCreator.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/ObjectCreator.java index a2a837b..c2dea2c 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/ObjectCreator.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/ObjectCreator.java @@ -10,9 +10,11 @@ public interface ObjectCreator { /** * Create an instance with specific type. * - * @param type type - * @param useCache useCache - * @return instance. + * @since 1.0.5 + * @param type type + * @param expectType expect java type. + * @param useCache useCache + * @return instance. */ - T create(String type, boolean useCache); + T create(String type, Class expectType, boolean useCache); } diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeAdapter.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeAdapter.java new file mode 100644 index 0000000..a127e0b --- /dev/null +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeAdapter.java @@ -0,0 +1,36 @@ +package org.smartboot.flow.helper.mock; + +import org.smartboot.flow.core.Adapter; +import org.smartboot.flow.core.EngineContext; +import org.smartboot.flow.core.common.Pair; + +/** + * Fake Class, do-nothing + * + * @author qinluo + * @date 2023/1/27 12:35 + * @since 1.0.0 + */ +public class FakeAdapter implements Adapter { + + private final String type; + + public FakeAdapter(String type) { + this.type = type; + } + + @Override + public Pair before(EngineContext context) { + return Pair.of(context.getReq(), context.getResult()); + } + + @Override + public void after(EngineContext origin, EngineContext newContext) { + + } + + @Override + public String describe() { + return type; + } +} diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeCondition.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeCondition.java new file mode 100644 index 0000000..25e0fca --- /dev/null +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeCondition.java @@ -0,0 +1,24 @@ +package org.smartboot.flow.helper.mock; + +import org.smartboot.flow.core.Condition; + +/** + * Fake Class, do-nothing + * + * @author qinluo + * @date 2023/1/27 12:35 + * @since 1.0.0 + */ +public class FakeCondition extends Condition { + + private final String type; + + public FakeCondition(String type) { + this.type = type; + } + + @Override + public String describe() { + return type; + } +} diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeExecutable.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeExecutable.java new file mode 100644 index 0000000..2fec968 --- /dev/null +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeExecutable.java @@ -0,0 +1,24 @@ +package org.smartboot.flow.helper.mock; + +import org.smartboot.flow.core.executable.AbstractExecutable; + +/** + * Fake Class, do-nothing + * + * @author qinluo + * @date 2023/1/27 12:35 + * @since 1.0.0 + */ +public class FakeExecutable extends AbstractExecutable { + + private final String type; + + public FakeExecutable(String type) { + this.type = type; + } + + @Override + public String describe() { + return type; + } +} diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeObjectCreator.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeObjectCreator.java new file mode 100644 index 0000000..d669732 --- /dev/null +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeObjectCreator.java @@ -0,0 +1,18 @@ +package org.smartboot.flow.helper.mock; + +import org.smartboot.flow.core.parser.ObjectCreator; + +/** + * Fake object creator, Return prepared fake object. + * + * @author qinluo + * @date 2023/1/27 12:20 + * @since 1.0.5 + */ +public class FakeObjectCreator implements ObjectCreator { + + @Override + public T create(String type, Class expectType, boolean useCache) { + return null; + } +} diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeScriptCondition.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeScriptCondition.java new file mode 100644 index 0000000..8eb1045 --- /dev/null +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeScriptCondition.java @@ -0,0 +1,36 @@ +package org.smartboot.flow.helper.mock; + +import org.smartboot.flow.core.EngineContext; +import org.smartboot.flow.core.script.ScriptCondition; + +/** + * Fake Class, do-nothing + * + * @author qinluo + * @date 2023/1/27 12:35 + * @since 1.0.0 + */ +public class FakeScriptCondition extends ScriptCondition { + + private final String type; + + public FakeScriptCondition(String type) { + this.type = type; + } + + @Override + public String getType() { + return type; + } + + @Override + public Object test(EngineContext context) { + // do-noting + return null; + } + + @Override + public String describe() { + return type; + } +} diff --git a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SpringObjectCreator.java b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SpringObjectCreator.java index 1f75d8d..242e1e3 100644 --- a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SpringObjectCreator.java +++ b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SpringObjectCreator.java @@ -17,14 +17,14 @@ public class SpringObjectCreator implements ObjectCreator, ApplicationContextAwa @Override @SuppressWarnings("unchecked") - public T create(String type, boolean useCache) { + public T create(String type, Class expectType, boolean useCache) { Object obj; try { // type as bean name. obj = ctx.getBean(type); } catch (BeansException ignored) { - obj = DefaultObjectCreator.getInstance().create(type, useCache); + obj = DefaultObjectCreator.getInstance().create(type, expectType, useCache); } return (T)obj; -- Gitee From aa3fecc11e0a4804a2addf023634e8a7f9942340 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Fri, 27 Jan 2023 12:49:04 +0800 Subject: [PATCH 03/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20FakeObjectCr?= =?UTF-8?q?eator=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attribute/AttributeValueResolver.java | 2 +- .../flow/helper/mock/FakeDegradeCallback.java | 26 +++++++++++++++++++ .../flow/helper/mock/FakeObjectCreator.java | 26 ++++++++++++++++++- 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeDegradeCallback.java diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/AttributeValueResolver.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/AttributeValueResolver.java index 368a153..b7c5037 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/AttributeValueResolver.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/AttributeValueResolver.java @@ -100,7 +100,7 @@ public class AttributeValueResolver { // for classname. try { - return objectCreator.create(strValue, null,true); + return objectCreator.create(strValue, attribute.accept,true); } catch (Exception ignored) { // Maybe not a class. } diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeDegradeCallback.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeDegradeCallback.java new file mode 100644 index 0000000..ecc23d7 --- /dev/null +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeDegradeCallback.java @@ -0,0 +1,26 @@ + +package org.smartboot.flow.helper.mock; + +import org.smartboot.flow.core.DegradeCallback; + +/** + * Fake Class, do-nothing + * + * @author qinluo + * @date 2023/1/27 12:35 + * @since 1.0.0 + */ +public class FakeDegradeCallback implements DegradeCallback { + + private final String type; + + public FakeDegradeCallback(String type) { + this.type = type; + } + + + @Override + public String describe() { + return type; + } +} diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeObjectCreator.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeObjectCreator.java index d669732..d367eee 100644 --- a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeObjectCreator.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/mock/FakeObjectCreator.java @@ -1,6 +1,12 @@ package org.smartboot.flow.helper.mock; +import org.smartboot.flow.core.Adapter; +import org.smartboot.flow.core.Condition; +import org.smartboot.flow.core.DegradeCallback; +import org.smartboot.flow.core.executable.Executable; +import org.smartboot.flow.core.parser.DefaultObjectCreator; import org.smartboot.flow.core.parser.ObjectCreator; +import org.smartboot.flow.core.script.ScriptCondition; /** * Fake object creator, Return prepared fake object. @@ -13,6 +19,24 @@ public class FakeObjectCreator implements ObjectCreator { @Override public T create(String type, Class expectType, boolean useCache) { - return null; + // Created by DefaultObjectCreator. + if (expectType == null) { + return DefaultObjectCreator.getInstance().create(type, null, useCache); + } + + if (expectType == Condition.class) { + return (T)new FakeCondition(type); + } else if (expectType == ScriptCondition.class) { + return (T)new FakeScriptCondition(type); + } else if (expectType == Executable.class) { + return (T)new FakeExecutable(type); + } else if (expectType == Adapter.class) { + return (T)new FakeAdapter(type); + } else if (expectType == DegradeCallback.class) { + return (T)new FakeDegradeCallback(type); + } + + // Default Created by DefaultObjectCreator. + return DefaultObjectCreator.getInstance().create(type, expectType, useCache); } } -- Gitee From 0f862cb57231a52ea3d5840e4c0fd64967154eb8 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Sun, 29 Jan 2023 15:28:17 +0800 Subject: [PATCH 04/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E5=BC=95=E6=93=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/smartboot/flow/core/FlowEngine.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java index 3c0958f..198bdf6 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java @@ -10,6 +10,8 @@ import org.smartboot.flow.core.util.AssertUtil; import org.smartboot.flow.core.visitor.EngineVisitor; import org.smartboot.flow.core.visitor.PipelineVisitor; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; @@ -32,6 +34,13 @@ public class FlowEngine implements Describable, Validator, Measurable { */ private final long startedAt = System.currentTimeMillis(); + /** + * Extension attributes. + * + * @since 1.0.5 + */ + private Map attributes = new HashMap<>(); + /* Used in async invoking */ private ExecutorService executor; @@ -136,6 +145,18 @@ public class FlowEngine implements Describable, Validator, Measurable { this.executor = executor; } + public String getAttribute(String key) { + return this.attributes.get(key); + } + + public void addAttribute(String key, String value) { + this.attributes.put(key, value); + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + /** * Return flow-engine created timestamp. * -- Gitee From e4133271020af4bdc291fe559cde5c0c393ec397 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Sun, 29 Jan 2023 18:21:24 +0800 Subject: [PATCH 05/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E5=BC=95?= =?UTF-8?q?=E6=93=8Exml=E5=BA=8F=E5=88=97=E5=8C=96=20=20=20=20=20=20-=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=82=E9=85=8D=E5=99=A8=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flow/core/component/AdapterComponent.java | 3 + .../flow/helper/view/XmlComponentVisitor.java | 149 ++++++++++++++++++ .../flow/helper/view/XmlEngineVisitor.java | 76 +++++++++ .../flow/helper/view/XmlPipelineVisitor.java | 76 +++++++++ 4 files changed, 304 insertions(+) create mode 100644 smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java create mode 100644 smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlEngineVisitor.java create mode 100644 smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/component/AdapterComponent.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/component/AdapterComponent.java index c2258a1..c14e65e 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/component/AdapterComponent.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/component/AdapterComponent.java @@ -93,6 +93,9 @@ public class AdapterComponent extends Component { @Override public void visit(ComponentVisitor visitor) { + visitor.visitAttributes(attributes); + visitor.visitSource(this); + visitor.visitExecutable(adapter.describe()); ComponentVisitor componentVisitor = visitor.visitComponent(component.getType(), component.getName(), component.describe()); if (componentVisitor != null) { component.visit(componentVisitor); diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java new file mode 100644 index 0000000..df42054 --- /dev/null +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java @@ -0,0 +1,149 @@ +package org.smartboot.flow.helper.view; + +import org.smartboot.flow.core.attribute.AttributeHolder; +import org.smartboot.flow.core.common.ComponentType; +import org.smartboot.flow.core.util.AuxiliaryUtils; +import org.smartboot.flow.core.visitor.ComponentVisitor; +import org.smartboot.flow.core.visitor.PipelineVisitor; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * @author yamikaze + * @date 2022/11/14 + * @since 1.0.5 + */ +public class XmlComponentVisitor extends ComponentVisitor { + + private final List attributes = new ArrayList<>(); + private final String name; + private final String describe; + // basic, if, choose, pipeline; + private final ComponentType type; + // Used with type pipeline. + private XmlPipelineVisitor pipeline; + private String condition; + private String branch; + private final List components = new ArrayList<>(); + /** + * 记录访问过的对象 + */ + private final Set visited; + private String executable; + + public XmlComponentVisitor(ComponentType type, String name, String describe, Set visited) { + this.name = name; + this.describe = describe; + this.type = type; + this.visited = visited; + } + + @Override + public void visitExecutable(String executable) { + this.executable = executable; + } + + @Override + public PipelineVisitor visitPipeline(String pipeline) { + this.pipeline = new XmlPipelineVisitor(pipeline, visited); + return this.pipeline; + } + + @Override + public void visitCondition(String condition) { + this.condition = condition; + } + + @Override + public ComponentVisitor visitComponent(ComponentType type, String name, String describe) { + XmlComponentVisitor component = new XmlComponentVisitor(type, name, describe, visited); + this.components.add(component); + return component; + } + + @Override + public void visitAttributes(List attributes) { + this.attributes.addAll(attributes); + } + + @Override + public ComponentVisitor visitBranch(Object branch, ComponentType type, String name, String describe) { + XmlComponentVisitor component = new XmlComponentVisitor(type, name, describe, visited); + component.branch = (String.valueOf(branch)); + this.components.add(component); + return component; + } + + private void appendAttributes(StringBuilder content) { + for (AttributeHolder ah : attributes) { + content.append(ah.getAttribute().name().toLowerCase()).append("=\"").append(ah.getValue().toString()).append("\" "); + } + } + + public void generate(StringBuilder content) { + String nodeName = AuxiliaryUtils.isBlank(name) ? describe : name; + ComponentType type = this.type; + + if (type == ComponentType.BASIC) { + content.append("\n"); + } else if (type == ComponentType.IF) { + content.append("\n"); + + content.append("\t\n"); + components.get(0).generate(content); + content.append("\n"); + + if (components.size() >= 2) { + content.append("\t\n"); + components.get(1).generate(content); + content.append("\n"); + } + content.append("\n"); + + } else if (type == ComponentType.CHOOSE) { + + content.append("\n"); + + for (XmlComponentVisitor component : components) { + if (component.branch != null) { + content.append("\t\n"); + component.generate(content); + content.append("\n"); + } else { + content.append("\t\n"); + component.generate(content); + content.append("\n"); + } + } + + content.append("\n"); + + } else if (type == ComponentType.PIPELINE) { + if (pipeline.isCycle()) { + content.append("\n"); + return; + } + + pipeline.generate(content); + } else if (type == ComponentType.ADAPTER) { + content.append("\n"); + XmlComponentVisitor pipeline = components.get(0); + pipeline.pipeline.generate(content); + content.append(""); + } + } + +} diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlEngineVisitor.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlEngineVisitor.java new file mode 100644 index 0000000..0b6c467 --- /dev/null +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlEngineVisitor.java @@ -0,0 +1,76 @@ +package org.smartboot.flow.helper.view; + +import org.smartboot.flow.core.FlowEngine; +import org.smartboot.flow.core.visitor.EngineVisitor; +import org.smartboot.flow.core.visitor.PipelineVisitor; + +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.Executor; + +/** + * @author qinluo + * @date 2022-11-14 19:48:14 + * @since 1.0.5 + */ +public class XmlEngineVisitor extends EngineVisitor { + + private static final String START = "\n\n" + + ""; + + private static final String END = ""; + + /** + * engine name. + */ + private String name; + private XmlPipelineVisitor pipeline; + + /** + * Xml content. + */ + private String content; + + /** + * 记录访问过的对象 + */ + private final Set visited = new HashSet<>(); + + public String getContent() { + return content; + } + + public void visit(FlowEngine engine) { + engine.visit(this); + } + + @Override + public void visitEnd() { + + StringBuilder content = new StringBuilder(); + content.append(START).append("\n"); + // + content.append("\t\n"); + + // Pipeline + this.pipeline.generate(content); + + content.append("\n").append(END).append("\n"); + + this.content = content.toString(); + } + + @Override + public void visit(String engine, Executor executor) { + this.name = engine; + } + + @Override + public PipelineVisitor visitPipeline(String pipeline) { + this.pipeline = new XmlPipelineVisitor(pipeline, visited); + return this.pipeline; + } +} diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java new file mode 100644 index 0000000..61216da --- /dev/null +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java @@ -0,0 +1,76 @@ +package org.smartboot.flow.helper.view; + +import org.smartboot.flow.core.Pipeline; +import org.smartboot.flow.core.common.ComponentType; +import org.smartboot.flow.core.visitor.ComponentVisitor; +import org.smartboot.flow.core.visitor.PipelineVisitor; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * @author yamikaze + * @date 2022/11/14 + * @since 1.0.5 + */ +public class XmlPipelineVisitor extends PipelineVisitor { + + private final String name; + private final List components = new ArrayList<>(); + /** + * 记录访问过的对象 + */ + private final Set visited; + private boolean cycle; + + public String getName() { + return name; + } + + public boolean isCycle() { + return cycle; + } + + public XmlPipelineVisitor(String name, Set visited) { + this.name = name; + this.visited = visited; + } + + public List getComponents() { + return components; + } + + @Override + public void visitSource(Pipeline pipeline) { + this.cycle = !visited.add(pipeline); + } + + @Override + public ComponentVisitor visitComponent(ComponentType type, String name, String describe) { + if (this.isCycle()) { + return null; + } + + XmlComponentVisitor component = new XmlComponentVisitor(type, name, describe, visited); + this.components.add(component); + return component; + } + + public void generate(StringBuilder content) { + + // + if (name != null && !name.contains("anonymous-pipeline")) { + content.append("\t\n\t\t"); + } + + for (XmlComponentVisitor component : components) { + component.generate(content); + } + + if (name != null && !name.contains("anonymous-pipeline")) { + content.append("\t"); + } + + } +} -- Gitee From 1180c55b38a8dc30294e6c6105c742503884c33b Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Mon, 30 Jan 2023 09:40:27 +0800 Subject: [PATCH 06/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../smartboot/flow/helper/view/XmlComponentVisitor.java | 8 +------- .../smartboot/flow/helper/view/XmlPipelineVisitor.java | 4 ---- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java index df42054..1493211 100644 --- a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java @@ -2,7 +2,6 @@ package org.smartboot.flow.helper.view; import org.smartboot.flow.core.attribute.AttributeHolder; import org.smartboot.flow.core.common.ComponentType; -import org.smartboot.flow.core.util.AuxiliaryUtils; import org.smartboot.flow.core.visitor.ComponentVisitor; import org.smartboot.flow.core.visitor.PipelineVisitor; @@ -18,8 +17,6 @@ import java.util.Set; public class XmlComponentVisitor extends ComponentVisitor { private final List attributes = new ArrayList<>(); - private final String name; - private final String describe; // basic, if, choose, pipeline; private final ComponentType type; // Used with type pipeline. @@ -34,8 +31,6 @@ public class XmlComponentVisitor extends ComponentVisitor { private String executable; public XmlComponentVisitor(ComponentType type, String name, String describe, Set visited) { - this.name = name; - this.describe = describe; this.type = type; this.visited = visited; } @@ -78,12 +73,11 @@ public class XmlComponentVisitor extends ComponentVisitor { private void appendAttributes(StringBuilder content) { for (AttributeHolder ah : attributes) { - content.append(ah.getAttribute().name().toLowerCase()).append("=\"").append(ah.getValue().toString()).append("\" "); + content.append(ah.getAttribute().getName()).append("=\"").append(ah.getValue().toString()).append("\" "); } } public void generate(StringBuilder content) { - String nodeName = AuxiliaryUtils.isBlank(name) ? describe : name; ComponentType type = this.type; if (type == ComponentType.BASIC) { diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java index 61216da..8241720 100644 --- a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java @@ -37,10 +37,6 @@ public class XmlPipelineVisitor extends PipelineVisitor { this.visited = visited; } - public List getComponents() { - return components; - } - @Override public void visitSource(Pipeline pipeline) { this.cycle = !visited.add(pipeline); -- Gitee From 40533d95474b141593d4feec33b477572ec349e3 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Mon, 30 Jan 2023 09:59:17 +0800 Subject: [PATCH 07/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E6=A0=BC=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flow/core/util/AuxiliaryUtils.java | 6 +++ .../flow/helper/view/XmlComponentVisitor.java | 43 +++++++++++++------ .../flow/helper/view/XmlEngineVisitor.java | 4 +- .../flow/helper/view/XmlPipelineVisitor.java | 15 ++++--- 4 files changed, 47 insertions(+), 21 deletions(-) diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/util/AuxiliaryUtils.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/util/AuxiliaryUtils.java index ed890c3..1b21359 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/util/AuxiliaryUtils.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/util/AuxiliaryUtils.java @@ -39,4 +39,10 @@ public final class AuxiliaryUtils { return null; } } + + public static void appendTab(StringBuilder sb, int numbersOfTab) { + for (int i = 0; i < numbersOfTab; i++) { + sb.append("\t"); + } + } } diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java index 1493211..c9e68d7 100644 --- a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java @@ -2,6 +2,7 @@ package org.smartboot.flow.helper.view; import org.smartboot.flow.core.attribute.AttributeHolder; import org.smartboot.flow.core.common.ComponentType; +import org.smartboot.flow.core.util.AuxiliaryUtils; import org.smartboot.flow.core.visitor.ComponentVisitor; import org.smartboot.flow.core.visitor.PipelineVisitor; @@ -77,51 +78,63 @@ public class XmlComponentVisitor extends ComponentVisitor { } } - public void generate(StringBuilder content) { + public void generate(StringBuilder content, int numbersOfTab) { ComponentType type = this.type; if (type == ComponentType.BASIC) { + AuxiliaryUtils.appendTab(content, numbersOfTab); content.append("\n"); } else if (type == ComponentType.IF) { + AuxiliaryUtils.appendTab(content, numbersOfTab); content.append("\n"); - content.append("\t\n"); - components.get(0).generate(content); + AuxiliaryUtils.appendTab(content, numbersOfTab + 1); + content.append("\n"); + components.get(0).generate(content, numbersOfTab + 2); + AuxiliaryUtils.appendTab(content, numbersOfTab + 1); content.append("\n"); if (components.size() >= 2) { - content.append("\t\n"); - components.get(1).generate(content); + AuxiliaryUtils.appendTab(content, numbersOfTab + 1); + content.append("\n"); + components.get(1).generate(content, numbersOfTab + 2); + AuxiliaryUtils.appendTab(content, numbersOfTab + 1); content.append("\n"); } + AuxiliaryUtils.appendTab(content, numbersOfTab); content.append("\n"); } else if (type == ComponentType.CHOOSE) { - + AuxiliaryUtils.appendTab(content, numbersOfTab); content.append("\n"); for (XmlComponentVisitor component : components) { if (component.branch != null) { - content.append("\t\n"); - component.generate(content); + AuxiliaryUtils.appendTab(content, numbersOfTab + 1); + content.append("\n"); + component.generate(content, numbersOfTab + 2); + AuxiliaryUtils.appendTab(content, numbersOfTab + 1); content.append("\n"); } else { - content.append("\t\n"); - component.generate(content); + AuxiliaryUtils.appendTab(content, numbersOfTab + 1); + content.append("\n"); + component.generate(content, numbersOfTab + 2); + AuxiliaryUtils.appendTab(content, numbersOfTab + 1); content.append("\n"); } } - + AuxiliaryUtils.appendTab(content, numbersOfTab); content.append("\n"); } else if (type == ComponentType.PIPELINE) { if (pipeline.isCycle()) { + AuxiliaryUtils.appendTab(content, numbersOfTab); content.append("\n"); XmlComponentVisitor pipeline = components.get(0); - pipeline.pipeline.generate(content); - content.append(""); + pipeline.pipeline.generate(content, numbersOfTab + 1); + AuxiliaryUtils.appendTab(content, numbersOfTab); + content.append("\n"); } } diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlEngineVisitor.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlEngineVisitor.java index 0b6c467..b760309 100644 --- a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlEngineVisitor.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlEngineVisitor.java @@ -53,10 +53,10 @@ public class XmlEngineVisitor extends EngineVisitor { StringBuilder content = new StringBuilder(); content.append(START).append("\n"); // - content.append("\t\n"); + content.append("\t\n"); // Pipeline - this.pipeline.generate(content); + this.pipeline.generate(content, 1); content.append("\n").append(END).append("\n"); diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java index 8241720..b1cc8d0 100644 --- a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java @@ -2,6 +2,7 @@ package org.smartboot.flow.helper.view; import org.smartboot.flow.core.Pipeline; import org.smartboot.flow.core.common.ComponentType; +import org.smartboot.flow.core.util.AuxiliaryUtils; import org.smartboot.flow.core.visitor.ComponentVisitor; import org.smartboot.flow.core.visitor.PipelineVisitor; @@ -53,19 +54,23 @@ public class XmlPipelineVisitor extends PipelineVisitor { return component; } - public void generate(StringBuilder content) { - + public void generate(StringBuilder content, int numbersOfTab) { + // for anonymous-pipeline + boolean incrementTab = false; // if (name != null && !name.contains("anonymous-pipeline")) { - content.append("\t\n\t\t"); + incrementTab = true; + AuxiliaryUtils.appendTab(content, numbersOfTab); + content.append("\n"); } for (XmlComponentVisitor component : components) { - component.generate(content); + component.generate(content, incrementTab ? numbersOfTab + 1 : numbersOfTab); } if (name != null && !name.contains("anonymous-pipeline")) { - content.append("\t"); + AuxiliaryUtils.appendTab(content, numbersOfTab); + content.append("\n"); } } -- Gitee From 6565c13056ea05f3695e34c73f8233533d4bf117 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Mon, 30 Jan 2023 10:12:54 +0800 Subject: [PATCH 08/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=9F=A5=E8=AF=A2SQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/smartboot/flow/manager/reload/SqlXmlSelector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/reload/SqlXmlSelector.java b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/reload/SqlXmlSelector.java index ca3f44b..2d30d12 100644 --- a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/reload/SqlXmlSelector.java +++ b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/reload/SqlXmlSelector.java @@ -19,7 +19,7 @@ public class SqlXmlSelector implements XmlSelector { /** * classpath*:/resources/init.sql */ - private final static String SELECT_SQL = "select content from engine_table where engine_name = ? limit 1"; + private final static String SELECT_SQL = "select content from engine_table where engine_name = ? and status = 0 limit 1"; private String url; private String username; private String password; -- Gitee From 65199aa22b43bc0f184fdc48f6cf59ed6a4bee92 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Mon, 30 Jan 2023 11:05:24 +0800 Subject: [PATCH 09/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E6=94=AF=E6=8C=81=E8=84=9A=E6=9C=AC=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/smartboot/flow/core/Condition.java | 7 ++++ .../flow/core/component/ChooseComponent.java | 6 ++- .../flow/core/component/IfComponent.java | 7 +++- .../manager/RegisteredComponentVisitor.java | 4 +- .../flow/core/script/ScriptCondition.java | 7 ++++ .../core/view/plantuml/PlantumlComponent.java | 4 +- .../flow/core/visitor/ComponentVisitor.java | 5 ++- .../flow/core/visitor/ConditionVisitor.java | 39 +++++++++++++++++++ .../flow/helper/view/ScriptCollector.java | 38 ++++++++++++++++++ .../flow/helper/view/XmlComponentVisitor.java | 17 +++++++- .../flow/helper/view/XmlEngineVisitor.java | 10 +++++ 11 files changed, 136 insertions(+), 8 deletions(-) create mode 100644 smart-flow-core/src/main/java/org/smartboot/flow/core/visitor/ConditionVisitor.java create mode 100644 smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/ScriptCollector.java diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/Condition.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/Condition.java index 24c956b..1e1a695 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/Condition.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/Condition.java @@ -1,5 +1,7 @@ package org.smartboot.flow.core; +import org.smartboot.flow.core.visitor.ConditionVisitor; + /** * @author qinluo * @date 2022-11-12 21:34:30 @@ -19,4 +21,9 @@ public abstract class Condition implements Describable { public String describe() { return this.getClass().getName(); } + + /* Visit condition's structure */ + public void visit(ConditionVisitor visitor) { + visitor.visitSource(this); + } } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/component/ChooseComponent.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/component/ChooseComponent.java index f11520b..dd8734e 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/component/ChooseComponent.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/component/ChooseComponent.java @@ -7,6 +7,7 @@ import org.smartboot.flow.core.Key; import org.smartboot.flow.core.common.ComponentType; import org.smartboot.flow.core.util.AssertUtil; import org.smartboot.flow.core.visitor.ComponentVisitor; +import org.smartboot.flow.core.visitor.ConditionVisitor; import java.util.Map; @@ -112,7 +113,10 @@ public class ChooseComponent extends Component { @Override public void visit(ComponentVisitor visitor) { visitor.visitAttributes(attributes); - visitor.visitCondition(condition.describe()); + ConditionVisitor conditionVisitor = visitor.visitCondition(condition.describe()); + if (conditionVisitor != null) { + condition.visit(conditionVisitor); + } visitor.visitSource(this); branches.forEach((k, v) -> { diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/component/IfComponent.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/component/IfComponent.java index a06ed12..f495930 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/component/IfComponent.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/component/IfComponent.java @@ -7,6 +7,7 @@ import org.smartboot.flow.core.Key; import org.smartboot.flow.core.common.ComponentType; import org.smartboot.flow.core.util.AssertUtil; import org.smartboot.flow.core.visitor.ComponentVisitor; +import org.smartboot.flow.core.visitor.ConditionVisitor; /** * @author qinluo @@ -93,7 +94,11 @@ public class IfComponent extends Component{ @Override public void visit(ComponentVisitor visitor) { visitor.visitAttributes(attributes); - visitor.visitCondition(condition.describe()); + ConditionVisitor conditionVisitor = visitor.visitCondition(condition.describe()); + if (conditionVisitor != null) { + condition.visit(conditionVisitor); + } + visitor.visitSource(this); ComponentVisitor thenVisitor = visitor.visitComponent(thenComponent.getType(), thenComponent.getName(), thenComponent.describe()); if (thenVisitor != null) { diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredComponentVisitor.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredComponentVisitor.java index 68f4376..bd615e0 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredComponentVisitor.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredComponentVisitor.java @@ -6,6 +6,7 @@ import org.smartboot.flow.core.component.Component; import org.smartboot.flow.core.util.AuxiliaryUtils; import org.smartboot.flow.core.util.ContactUtils; import org.smartboot.flow.core.visitor.ComponentVisitor; +import org.smartboot.flow.core.visitor.ConditionVisitor; import org.smartboot.flow.core.visitor.PipelineVisitor; import java.util.List; @@ -39,8 +40,9 @@ public class RegisteredComponentVisitor extends ComponentVisitor { } @Override - public void visitCondition(String condition) { + public ConditionVisitor visitCondition(String condition) { this.model.condition = (condition); + return null; } @Override diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptCondition.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptCondition.java index 5ebe2ec..31a858e 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptCondition.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptCondition.java @@ -2,6 +2,7 @@ package org.smartboot.flow.core.script; import org.smartboot.flow.core.EngineContext; import org.smartboot.flow.core.NamedCondition; +import org.smartboot.flow.core.visitor.ConditionVisitor; import java.util.Map; @@ -59,4 +60,10 @@ public abstract class ScriptCondition extends NamedCondition { public String describe() { return "script-" + getType() + "-" + super.describe(); } + + @Override + public void visit(ConditionVisitor visitor) { + visitor.visitScript(script); + super.visit(visitor); + } } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/PlantumlComponent.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/PlantumlComponent.java index cc81ab4..f4504b6 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/PlantumlComponent.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/PlantumlComponent.java @@ -5,6 +5,7 @@ import org.smartboot.flow.core.attribute.AttributeHolder; import org.smartboot.flow.core.attribute.Attributes; import org.smartboot.flow.core.util.AuxiliaryUtils; import org.smartboot.flow.core.visitor.ComponentVisitor; +import org.smartboot.flow.core.visitor.ConditionVisitor; import org.smartboot.flow.core.visitor.PipelineVisitor; import java.util.ArrayList; @@ -47,8 +48,9 @@ public class PlantumlComponent extends ComponentVisitor { } @Override - public void visitCondition(String condition) { + public ConditionVisitor visitCondition(String condition) { this.condition = condition; + return null; } @Override diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/visitor/ComponentVisitor.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/visitor/ComponentVisitor.java index 77ff493..3abce81 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/visitor/ComponentVisitor.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/visitor/ComponentVisitor.java @@ -37,10 +37,11 @@ public class ComponentVisitor { } } - public void visitCondition(String condition) { + public ConditionVisitor visitCondition(String condition) { if (delegate != null) { - delegate.visitCondition(condition); + return delegate.visitCondition(condition); } + return null; } /** diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/visitor/ConditionVisitor.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/visitor/ConditionVisitor.java new file mode 100644 index 0000000..5723643 --- /dev/null +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/visitor/ConditionVisitor.java @@ -0,0 +1,39 @@ +package org.smartboot.flow.core.visitor; + +import org.smartboot.flow.core.Condition; + +/** + * @author qinluo + * @date 2022-11-13 22:34:58 + * @since 1.0.5 + */ +public class ConditionVisitor { + + protected ConditionVisitor delegate; + + public ConditionVisitor() { + this(null); + } + + public ConditionVisitor(ConditionVisitor delegate) { + this.delegate = delegate; + } + + /** + * Visit pipeline source. + */ + public void visitSource(Condition condition) { + if (delegate != null) { + delegate.visitSource(condition); + } + } + + /** + * Visit script. + */ + public void visitScript(String script) { + if (delegate != null) { + delegate.visitScript(script); + } + } +} diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/ScriptCollector.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/ScriptCollector.java new file mode 100644 index 0000000..501a045 --- /dev/null +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/ScriptCollector.java @@ -0,0 +1,38 @@ +package org.smartboot.flow.helper.view; + +import java.util.HashMap; +import java.util.Map; + +/** + * Collect scripts in engine. + * + * @author qinluo + * @date 2023-01-29 10:47:46 + * @since 1.0.5 + */ +public class ScriptCollector { + + private static final ThreadLocal HOLDER = new ThreadLocal<>(); + private final Map scripts = new HashMap<>(); + + public static void start() { + HOLDER.set(new ScriptCollector()); + } + + public static void collect(String condition, String script) { + ScriptCollector collector = HOLDER.get(); + if (collector != null) { + collector.scripts.put(condition, script); + } + } + + public static Map end() { + ScriptCollector collector = HOLDER.get(); + if (collector != null) { + HOLDER.remove(); + return collector.scripts; + } + + return null; + } +} diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java index c9e68d7..8b5b748 100644 --- a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java @@ -4,6 +4,7 @@ import org.smartboot.flow.core.attribute.AttributeHolder; import org.smartboot.flow.core.common.ComponentType; import org.smartboot.flow.core.util.AuxiliaryUtils; import org.smartboot.flow.core.visitor.ComponentVisitor; +import org.smartboot.flow.core.visitor.ConditionVisitor; import org.smartboot.flow.core.visitor.PipelineVisitor; import java.util.ArrayList; @@ -30,6 +31,7 @@ public class XmlComponentVisitor extends ComponentVisitor { */ private final Set visited; private String executable; + private String script; public XmlComponentVisitor(ComponentType type, String name, String describe, Set visited) { this.type = type; @@ -48,8 +50,9 @@ public class XmlComponentVisitor extends ComponentVisitor { } @Override - public void visitCondition(String condition) { + public ConditionVisitor visitCondition(String condition) { this.condition = condition; + return new XmlConditionVisitor(); } @Override @@ -81,6 +84,10 @@ public class XmlComponentVisitor extends ComponentVisitor { public void generate(StringBuilder content, int numbersOfTab) { ComponentType type = this.type; + if (script != null) { + ScriptCollector.collect(condition, script); + } + if (type == ComponentType.BASIC) { AuxiliaryUtils.appendTab(content, numbersOfTab); content.append("\n"); - } else if (type == ComponentType.CHOOSE) { AuxiliaryUtils.appendTab(content, numbersOfTab); content.append(" scripts = ScriptCollector.end(); + if (scripts != null && scripts.size() > 0) { + scripts.forEach((k, v) -> { + content.append("\t"); + }); + } + content.append("\n").append(END).append("\n"); this.content = content.toString(); -- Gitee From 761c7e927c346c1fa11883402eec669639cee7dd Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Mon, 30 Jan 2023 11:10:09 +0800 Subject: [PATCH 10/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E6=94=AF=E6=8C=81=E8=84=9A=E6=9C=AC=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/smartboot/flow/helper/view/XmlEngineVisitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlEngineVisitor.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlEngineVisitor.java index 16692f7..b91be98 100644 --- a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlEngineVisitor.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlEngineVisitor.java @@ -63,7 +63,7 @@ public class XmlEngineVisitor extends EngineVisitor { Map scripts = ScriptCollector.end(); if (scripts != null && scripts.size() > 0) { scripts.forEach((k, v) -> { - content.append("\t"); }); } -- Gitee From 72124f6442f6bc33b2348e86c3c4d895ffc23835 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Mon, 30 Jan 2023 14:04:06 +0800 Subject: [PATCH 11/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smart-flow-manager/pom.xml | 6 +++ .../src/main/resources/init.sql | 52 ++++++++++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/smart-flow-manager/pom.xml b/smart-flow-manager/pom.xml index 89b2328..c3ee046 100644 --- a/smart-flow-manager/pom.xml +++ b/smart-flow-manager/pom.xml @@ -23,6 +23,12 @@ 1.0.5-SNAPSHOT + + org.smartboot.flow + smart-flow-helper + 1.0.5-SNAPSHOT + + org.smartboot.http smart-http-client diff --git a/smart-flow-manager/src/main/resources/init.sql b/smart-flow-manager/src/main/resources/init.sql index 5cba42c..1609f51 100644 --- a/smart-flow-manager/src/main/resources/init.sql +++ b/smart-flow-manager/src/main/resources/init.sql @@ -1,8 +1,56 @@ +-- 引擎表 CREATE TABLE `engine_table` ( `id` bigint NOT NULL AUTO_INCREMENT, `engine_name` varchar(256) NOT NULL COMMENT '引擎名称,唯一', `content` text COMMENT '引擎配置内容,必须是xml形式', + `version` int NOT NULL DEFAULT '1' COMMENT '版本', `status` int NOT NULL DEFAULT '0' COMMENT '状态 0-正常 1-删除', + `created` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updated` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`id`), - UNIQUE KEY `engine_table_engine_name_uindex` (`engine_name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='引擎配置表' \ No newline at end of file + UNIQUE KEY `uk_engine_name` (`engine_name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='引擎配置表'; + +-- 引擎历史表 +CREATE TABLE `engine_table_history` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `engine_id` bigint NOT NULL COMMENT '引擎id', + `engine_name` varchar(256) NOT NULL COMMENT '引擎名称', + `content` text COMMENT '引擎配置内容,必须是xml形式', + `version` int NOT NULL DEFAULT '1' COMMENT '版本', + `created` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updated` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='引擎历史记录表' + +-- 引擎结构快照 +CREATE TABLE `engine_table_snapshot` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `engine_name` varchar(256) NOT NULL COMMENT '引擎名称', + `content` text COMMENT '引擎配置内容,必须是xml形式', + `md5` varchar(256) COMMENT 'content md5加密字符串', + `created` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updated` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_md5` (`md5`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='引擎快照表' + +-- 执行耗时 +CREATE TABLE `engine_table_metrics` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `engine_name` varchar(256) NOT NULL COMMENT '引擎名称', + `content` text COMMENT 'json格式', + `created` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updated` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='引擎执行数据表' + +-- 执行trace +CREATE TABLE `engine_table_trace` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `engine_name` varchar(256) NOT NULL COMMENT '引擎名称', + `content` text COMMENT 'json格式', + `created` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updated` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`), +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='引擎执行链路表' \ No newline at end of file -- Gitee From 8f20030fb5b49c82680865bf79a287bdafd2e7b0 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Mon, 30 Jan 2023 22:49:08 +0800 Subject: [PATCH 12/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=8A=9F=E8=83=BDlistener=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/ManagerExecutionListener.java | 31 +++++++++++++++++++ .../smartboot/flow/manager/ManagerKeys.java | 24 ++++++++++++++ .../flow/manager/TraceIdGenerator.java | 28 +++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerExecutionListener.java create mode 100644 smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerKeys.java create mode 100644 smart-flow-manager/src/main/java/org/smartboot/flow/manager/TraceIdGenerator.java diff --git a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerExecutionListener.java b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerExecutionListener.java new file mode 100644 index 0000000..ea1122f --- /dev/null +++ b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerExecutionListener.java @@ -0,0 +1,31 @@ +package org.smartboot.flow.manager; + +import org.smartboot.flow.core.EngineContext; +import org.smartboot.flow.core.ExecutionListenerSupport; + +/** + * 由管理模块进行Listener的注册 + * + * @author qinluo + * @date 2023/1/30 22:42 + * @since 1.0.0 + */ +public class ManagerExecutionListener extends ExecutionListenerSupport { + + @Override + public void start(EngineContext context) { + TraceIdGenerator generator = TraceIdGenerator.getTraceIdGenerator(); + if (generator != null) { + context.putExt(ManagerKeys.traceId, generator.getTraceId(context)); + } + + // 暂时init个object + context.putExt(ManagerKeys.traces, new Object()); + + } + + @Override + public void completed(EngineContext context) { + // 将执行采集到的数据进行上报 + } +} diff --git a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerKeys.java b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerKeys.java new file mode 100644 index 0000000..781e4ba --- /dev/null +++ b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerKeys.java @@ -0,0 +1,24 @@ +package org.smartboot.flow.manager; + +import org.smartboot.flow.core.Key; + +/** + * @author qinluo + * @date 2023/1/30 22:43 + * @since 1.0.0 + */ +public interface ManagerKeys { + + /** + * TraceId key in engine ctx. + */ + Key traceId = Key.of("traceId"); + + /** + * Invoke trace in engine invoking. + * + */ + Key traces = Key.of("traces"); + + +} diff --git a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/TraceIdGenerator.java b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/TraceIdGenerator.java new file mode 100644 index 0000000..054e1d5 --- /dev/null +++ b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/TraceIdGenerator.java @@ -0,0 +1,28 @@ +package org.smartboot.flow.manager; + +import org.smartboot.flow.core.EngineContext; + +import java.util.UUID; + +/** + * @author qinluo + * @date 2023/1/30 22:37 + * @since 1.0.0 + */ +public class TraceIdGenerator { + + private static TraceIdGenerator traceIdGenerator = new TraceIdGenerator(); + + public String getTraceId(EngineContext ctx) { + // 默认UUID实现 + return UUID.randomUUID().toString().replace("-", ""); + } + + public static TraceIdGenerator getTraceIdGenerator() { + return traceIdGenerator; + } + + public static void setTraceIdGenerator(TraceIdGenerator generator) { + traceIdGenerator = generator; + } +} -- Gitee From e7f908e2404662076b90a4617083845965c299b2 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Tue, 31 Jan 2023 13:53:46 +0800 Subject: [PATCH 13/20] qinluo: - fix adapter. --- .../smartboot/flow/core/parser/BuilderDefinitionVisitor.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/BuilderDefinitionVisitor.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/BuilderDefinitionVisitor.java index 6fbbd40..044d0ff 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/BuilderDefinitionVisitor.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/BuilderDefinitionVisitor.java @@ -250,10 +250,7 @@ public class BuilderDefinitionVisitor implements DefinitionVisitor { @Override public void visit(AdapterDefinition ed) { String execute = ed.getExecute(); - Adapter adapter = null; - if (AuxiliaryUtils.isType(execute)) { - adapter = newInstance(execute, Adapter.class); - } + Adapter adapter = newInstance(execute, Adapter.class); AssertUtil.notNull(adapter, "can't find adapter , execute=" + execute); ed.getPipelineElement().visit(this); -- Gitee From 30538af7bc18fb9a4326abc8ee083b6ccb010250 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Tue, 31 Jan 2023 23:59:19 +0800 Subject: [PATCH 14/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20spring=20rel?= =?UTF-8?q?oad=E9=80=9A=E7=9F=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spring/extension/EnableReloadNotify.java | 21 ++++ .../spring/extension/NotifierProcessor.java | 64 ++++++++++ .../flow/spring/extension/ProxyParser.java | 1 + .../spring/extension/ReflectionNotifier.java | 117 ++++++++++++++++++ .../flow/spring/extension/ReloadNotify.java | 28 +++++ .../spring/extension/SmartFlowRegistrar.java | 37 ++++++ 6 files changed, 268 insertions(+) create mode 100644 smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/EnableReloadNotify.java create mode 100644 smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NotifierProcessor.java create mode 100644 smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/ReflectionNotifier.java create mode 100644 smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/ReloadNotify.java create mode 100644 smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SmartFlowRegistrar.java diff --git a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/EnableReloadNotify.java b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/EnableReloadNotify.java new file mode 100644 index 0000000..1b8ea79 --- /dev/null +++ b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/EnableReloadNotify.java @@ -0,0 +1,21 @@ +package org.smartboot.flow.spring.extension; + +import org.springframework.context.annotation.Import; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 开启引擎reload通知 + * + * @author qinluo + * @date 2023/1/31 22:16 + * @since 1.0.0 + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Import(SmartFlowRegistrar.class) +public @interface EnableReloadNotify { +} diff --git a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NotifierProcessor.java b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NotifierProcessor.java new file mode 100644 index 0000000..d5ef8ca --- /dev/null +++ b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NotifierProcessor.java @@ -0,0 +1,64 @@ +package org.smartboot.flow.spring.extension; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.smartboot.flow.core.FlowEngine; +import org.smartboot.flow.core.util.AuxiliaryUtils; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.BeanFactoryAware; +import org.springframework.beans.factory.config.BeanPostProcessor; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.util.ReflectionUtils; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; + +/** + * @author qinluo + * @date 2023/1/31 22:15 + * @since 1.0.0 + */ +public class NotifierProcessor implements BeanPostProcessor, BeanFactoryAware { + + private static final Logger LOGGER = LoggerFactory.getLogger(NotifierProcessor.class); + + private ReflectionNotifier notifier; + + @Override + public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { + extraNotifyFields(bean, beanName); + + return bean; + } + + private void extraNotifyFields(Object bean, String beanName) { + try { + ReflectionUtils.doWithFields(bean.getClass(), field -> { + field.setAccessible(true); + ReloadNotify conf = field.getAnnotation(ReloadNotify.class); + if (FlowEngine.class.isAssignableFrom(field.getType())) { + String engineName = AuxiliaryUtils.or(conf.value()[0], field.getName()); + notifier.addNotifyField(field, bean, Collections.singletonList(engineName)); + } else if (Map.class.isAssignableFrom(field.getType())) { + notifier.addNotifyField(field, bean, Arrays.asList(conf.value())); + } + + }, field -> field.isAnnotationPresent(ReloadNotify.class)); + } catch (Exception e) { + LOGGER.error("process bean failed, bean = {}", beanName, e); + } + } + + @Override + public void setBeanFactory(BeanFactory beanFactory) throws BeansException { + if (beanFactory instanceof DefaultListableBeanFactory) { + ((DefaultListableBeanFactory)beanFactory).setAllowBeanDefinitionOverriding(true); + notifier = new ReflectionNotifier(beanFactory); + notifier.register(); + } + + } +} diff --git a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/ProxyParser.java b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/ProxyParser.java index e151da6..4e6d94e 100644 --- a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/ProxyParser.java +++ b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/ProxyParser.java @@ -18,6 +18,7 @@ public class ProxyParser implements BeanDefinitionParser { @Override public BeanDefinition parse(Element element, ParserContext parserContext) { + SmartFlowRegistrar.registerAll(parserContext.getRegistry()); org.smartboot.flow.core.parser.ParserContext context = new org.smartboot.flow.core.parser.ParserContext(); // Ensure identifier in spring scope is unique. context.setIdentifierManager(new SpringIdentifierManager(parserContext.getRegistry())); diff --git a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/ReflectionNotifier.java b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/ReflectionNotifier.java new file mode 100644 index 0000000..a703f3a --- /dev/null +++ b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/ReflectionNotifier.java @@ -0,0 +1,117 @@ +package org.smartboot.flow.spring.extension; + +import org.smartboot.flow.core.FlowEngine; +import org.smartboot.flow.core.manager.DefaultEngineManager; +import org.smartboot.flow.core.manager.EngineModel; +import org.smartboot.flow.core.util.AuxiliaryUtils; +import org.smartboot.flow.manager.reload.ReloadListener; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.util.ReflectionUtils; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.CopyOnWriteArrayList; + +/** + * @author qinluo + * @date 2023/1/31 23:17 + * @since 1.0.0 + */ +public class ReflectionNotifier implements ReloadListener { + + private final BeanFactory factory; + private final List notifiers = new CopyOnWriteArrayList<>(); + + public ReflectionNotifier(BeanFactory factory) { + this.factory = factory; + } + + @Override + public void onload(String engineName) { + + } + + @Override + public void loadCompleted(String engineName, Throwable e) { + if (e != null) { + return; + } + + FlowEngine engineInstance = null; + FlowEngine springEngine = null; + FlowEngine managerEngine = null; + try { + springEngine = (FlowEngine)factory.getBean(engineName); + } catch (Exception ex) { + // do-nothing + } + + EngineModel engineModel = DefaultEngineManager.getDefaultManager().getEngineModel(engineName); + if (engineModel != null) { + managerEngine = engineModel.getSource(); + } + + if (springEngine == null ^ managerEngine == null) { + engineInstance = AuxiliaryUtils.or(springEngine, managerEngine); + } else if (springEngine != null) { + if (springEngine.getStartedAt() > managerEngine.getStartedAt()) { + engineInstance = springEngine; + } else if(springEngine.getStartedAt() < managerEngine.getStartedAt()){ + engineInstance = managerEngine; + } + } + + // Cannot find engine instance. + if (engineInstance == null) { + return; + } + + for (NotifyConf conf : notifiers) { + conf.notify(engineName, engineInstance); + } + + } + + public void addNotifyField(Field field, Object bean, List accepted) { + notifiers.add(new NotifyConf(field, bean, accepted)); + } + + private static class NotifyConf { + private final Field f; + private final Object bean; + private final List accepted; + private final boolean acceptAny; + + public NotifyConf(Field f, Object bean, List accepted) { + this.f = f; + this.bean = bean; + this.accepted = accepted; + this.acceptAny = accepted.size() == 1 && Objects.equals(accepted.get(0), ""); + } + + public void notify(String engineName, FlowEngine engineInstance) { + if (!acceptAny && !accepted.contains(engineName)) { + return; + } + + if (FlowEngine.class.isAssignableFrom(f.getType())) { + ReflectionUtils.setField(f, bean, engineInstance); + } else if ((Map.class.isAssignableFrom(f.getType()))) { + Map engines = (Map)ReflectionUtils.getField(f, bean); + if (engines == null) { + return; + } + + Object o = engines.get(engineName); + if (o instanceof FlowEngine) { + engines.put(engineName, engineInstance); + } + + } + + + } + } +} diff --git a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/ReloadNotify.java b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/ReloadNotify.java new file mode 100644 index 0000000..1b10157 --- /dev/null +++ b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/ReloadNotify.java @@ -0,0 +1,28 @@ +package org.smartboot.flow.spring.extension; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 标注引擎更新 + * + * @author qinluo + * @date 2023/1/31 21:53 + * @since 1.0.0 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface ReloadNotify { + + /** + * 需要通知的引擎名称列表 + * 当修饰单个引擎字段时,value值为引擎名称,不指定则属性字段名为引擎名称 + * 当修饰map时,可以指定引擎名称列表,如果不指定则默认所有引擎都会注册到map中 + * + * + * @return 引擎名称 + */ + String[] value() default ""; +} diff --git a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SmartFlowRegistrar.java b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SmartFlowRegistrar.java new file mode 100644 index 0000000..cc3818e --- /dev/null +++ b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SmartFlowRegistrar.java @@ -0,0 +1,37 @@ +package org.smartboot.flow.spring.extension; + +import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.beans.factory.support.BeanNameGenerator; +import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; +import org.springframework.core.type.AnnotationMetadata; + +/** + * @author qinluo + * @date 2023/1/31 22:15 + * @since 1.0.0 + */ +public class SmartFlowRegistrar implements ImportBeanDefinitionRegistrar { + + private static volatile boolean registered = false; + private static final String NOTIFIER_PROCESS = "smart-flow-notifer-processor"; + + @Override + public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry, BeanNameGenerator importBeanNameGenerator) { + registerAll(registry); + } + + public static void registerAll(BeanDefinitionRegistry registry) { + registerNotifier(registry); + } + + private static void registerNotifier(BeanDefinitionRegistry registry) { + if (registered) { + return; + } + registered = true; + RootBeanDefinition definition = new RootBeanDefinition(); + definition.setBeanClass(NotifierProcessor.class); + registry.registerBeanDefinition(NOTIFIER_PROCESS, definition); + } +} -- Gitee From 7f61196dc3240d12f9ecf57b7dbffa0a2651f1bc Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Wed, 1 Feb 2023 00:26:58 +0800 Subject: [PATCH 15/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/smartboot/flow/spring/extension/NotifierProcessor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NotifierProcessor.java b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NotifierProcessor.java index d5ef8ca..bbd464e 100644 --- a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NotifierProcessor.java +++ b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NotifierProcessor.java @@ -8,7 +8,6 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.util.ReflectionUtils; -- Gitee From bd67329d17c249f9a33c888413b6defe0366c04e Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Wed, 1 Feb 2023 22:06:59 +0800 Subject: [PATCH 16/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/smartboot/flow/core/Condition.java | 4 +++- .../smartboot/flow/core/DegradeCallback.java | 11 ++++++++++ .../smartboot/flow/core/EngineConstants.java | 16 ++++++++++++++ .../org/smartboot/flow/core/FlowEngine.java | 4 +--- .../org/smartboot/flow/core/Pipeline.java | 2 -- .../flow/core/attribute/AttributeHolder.java | 2 +- .../flow/core/attribute/Attributes.java | 3 +++ .../flow/core/builder/AdapterBuilder.java | 1 + .../flow/core/builder/ChooseBuilder.java | 1 + .../flow/core/builder/ExecutableBuilder.java | 1 + .../flow/core/builder/IfComponentBuilder.java | 1 + .../flow/core/common/ComponentType.java | 21 +++++++++++++++++++ .../flow/core/component/Component.java | 4 ++-- .../flow/core/exception/ExceptionHandler.java | 8 +++++++ .../core/executable/AbstractExecutable.java | 1 + .../flow/core/executable/Executable.java | 5 +++++ .../core/executable/ExecutableAdapter.java | 1 + .../flow/core/invoker/InvokeListener.java | 8 +++++++ .../flow/core/manager/ComponentModel.java | 6 ++---- .../core/manager/RegisterEngineVisitor.java | 4 ++-- .../manager/RegisteredComponentVisitor.java | 1 - .../manager/RegisteredPipelineVisitor.java | 3 +-- .../core/metrics/MetricExecutionListener.java | 2 +- .../flow/core/metrics/MetricKind.java | 6 ++++++ .../core/parser/BuilderDefinitionVisitor.java | 9 +++++++- .../flow/core/parser/DefaultParser.java | 2 +- .../flow/core/parser/ParserContext.java | 2 +- .../flow/core/parser/PipelineEndCallBack.java | 13 ------------ .../flow/core/script/ScriptCondition.java | 6 ++++++ .../core/script/ScriptVariableManager.java | 2 +- .../org/smartboot/flow/core/trace/Node.java | 4 +++- .../flow/core/util/AuxiliaryUtils.java | 11 ++++++++++ .../flow/core/util/ContactUtils.java | 20 ------------------ .../flow/core/visitor/ConditionVisitor.java | 2 +- .../smartboot/flow/helper/view}/Color.java | 2 +- .../flow/helper/view}/PlantumlComponent.java | 6 ++---- .../helper/view}/PlantumlEngineVisitor.java | 4 ++-- .../flow/helper/view}/PlantumlPipeline.java | 2 +- .../flow/helper/view/XmlComponentVisitor.java | 4 +--- .../flow/helper/view/XmlPipelineVisitor.java | 5 +++-- .../flow/manager/ManagerConstants.java | 14 +++++++++++++ .../manager/ManagerExecutionListener.java | 4 ++-- .../smartboot/flow/manager/ManagerKeys.java | 4 ++-- .../flow/manager/change/HttpManager.java | 3 ++- .../flow/manager/reload/ReloadListener.java | 15 ++++++++++++- .../groovy/GroovyScriptCondition.java | 4 ++-- .../extension/groovy/JavaScriptCondition.java | 1 + .../extension/ognl/OgnlScriptCondition.java | 2 +- .../extension/BeanDefinitionRegister.java | 4 ---- .../spring/extension/NameAwareCondition.java | 1 - .../extension/NamedAbstractExecutable.java | 1 - 51 files changed, 177 insertions(+), 86 deletions(-) create mode 100644 smart-flow-core/src/main/java/org/smartboot/flow/core/EngineConstants.java delete mode 100644 smart-flow-core/src/main/java/org/smartboot/flow/core/parser/PipelineEndCallBack.java delete mode 100644 smart-flow-core/src/main/java/org/smartboot/flow/core/util/ContactUtils.java rename {smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml => smart-flow-helper/src/main/java/org/smartboot/flow/helper/view}/Color.java (94%) rename {smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml => smart-flow-helper/src/main/java/org/smartboot/flow/helper/view}/PlantumlComponent.java (97%) rename {smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml => smart-flow-helper/src/main/java/org/smartboot/flow/helper/view}/PlantumlEngineVisitor.java (97%) rename {smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml => smart-flow-helper/src/main/java/org/smartboot/flow/helper/view}/PlantumlPipeline.java (97%) create mode 100644 smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerConstants.java diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/Condition.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/Condition.java index 1e1a695..34daf2d 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/Condition.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/Condition.java @@ -22,7 +22,9 @@ public abstract class Condition implements Describable { return this.getClass().getName(); } - /* Visit condition's structure */ + /** + * Visit condition's structure + */ public void visit(ConditionVisitor visitor) { visitor.visitSource(this); } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/DegradeCallback.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/DegradeCallback.java index cbc0aac..02f9a8e 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/DegradeCallback.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/DegradeCallback.java @@ -7,10 +7,21 @@ package org.smartboot.flow.core; */ public interface DegradeCallback extends Describable { + /** + * 降级回调通知 + * + * @param context 执行上下文 + * @param e 当前组件出现的异常 + */ default void doWithDegrade(EngineContext context, Throwable e) { } + /** + * 降级回调描述 + * + * @return 默认为classname + */ @Override default String describe() { return this.getClass().getName(); diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/EngineConstants.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/EngineConstants.java new file mode 100644 index 0000000..54b59ce --- /dev/null +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/EngineConstants.java @@ -0,0 +1,16 @@ +package org.smartboot.flow.core; + +/** + * @author qinluo + * @date 2023/2/1 21:52 + * @since 1.0.0 + */ +public interface EngineConstants { + + /** + * 匿名Pipeline前缀 + */ + String ANONYMOUS_PREFIX = "anonymous-pipeline"; + + int TAB_SIZE = 4; +} diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java index 198bdf6..464b20b 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java @@ -41,7 +41,7 @@ public class FlowEngine implements Describable, Validator, Measurable { */ private Map attributes = new HashMap<>(); - /* Used in async invoking */ + /** Used in async invoking */ private ExecutorService executor; public EngineContext execute(T t) { @@ -102,8 +102,6 @@ public class FlowEngine implements Describable, Validator, Measurable { context.listener.completed(context); } - - protected void initContext(EngineContext context) { context.clear(); context.setHandler(exceptionHandler); diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/Pipeline.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/Pipeline.java index 9ca9da7..8f9ae29 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/Pipeline.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/Pipeline.java @@ -10,9 +10,7 @@ import org.smartboot.flow.core.visitor.ComponentVisitor; import org.smartboot.flow.core.visitor.PipelineVisitor; import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import java.util.concurrent.Future; /** * @author qinluo diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/AttributeHolder.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/AttributeHolder.java index c7f7b02..727bb78 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/AttributeHolder.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/AttributeHolder.java @@ -10,7 +10,7 @@ public class AttributeHolder { private final Attributes attribute; private Object value; - public AttributeHolder(Attributes attribute, Object value) { + private AttributeHolder(Attributes attribute, Object value) { this.attribute = attribute; this.value = value; } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/Attributes.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/Attributes.java index 835078e..19d485a 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/Attributes.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/attribute/Attributes.java @@ -15,6 +15,9 @@ import java.util.List; @SuppressWarnings("unchecked") public enum Attributes { + /** + * name + */ NAME("name", String.class) { @Override public void apply(Component component, Object value) { diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/AdapterBuilder.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/AdapterBuilder.java index af38027..143804e 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/AdapterBuilder.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/AdapterBuilder.java @@ -31,6 +31,7 @@ public class AdapterBuilder extends ExecutableBuilder { /** * Resolve return type. */ + @Override public AdapterBuilder apply(Attributes attributes, Object value) { super.apply(attributes, value); return this; diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/ChooseBuilder.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/ChooseBuilder.java index fab6a21..cccbf55 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/ChooseBuilder.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/ChooseBuilder.java @@ -77,6 +77,7 @@ public class ChooseBuilder extends ExecutableBuilder { return pipelineBuilder.next(chooseComponent); } + @Override public ChooseBuilder apply(Attributes attributes, Object value) { super.apply(attributes, value); return this; diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/ExecutableBuilder.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/ExecutableBuilder.java index db2e27e..122c436 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/ExecutableBuilder.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/ExecutableBuilder.java @@ -29,6 +29,7 @@ public class ExecutableBuilder extends AbstractComponentBuilder { return new ExecutableAdapter<>(executable); } + @Override public ExecutableBuilder apply(Attributes attributes, Object value) { super.apply(attributes, value); return this; diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/IfComponentBuilder.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/IfComponentBuilder.java index f38b266..cd08544 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/IfComponentBuilder.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/IfComponentBuilder.java @@ -35,6 +35,7 @@ public class IfComponentBuilder extends ExecutableBuilder{ this.condition = condition; } + @Override public IfComponentBuilder apply(Attributes attributes, Object value) { super.apply(attributes, value); return this; diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/common/ComponentType.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/common/ComponentType.java index 942b9f2..8a27998 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/common/ComponentType.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/common/ComponentType.java @@ -1,15 +1,36 @@ package org.smartboot.flow.core.common; /** + * 组件类型 + * * @author yamikaze * @date 2022/11/14 */ public enum ComponentType { + /** + * 基本组件 + */ BASIC, + + /** + * IF分支选择组件 + */ IF, + + /** + * CHOOSE分支选择组件 + */ CHOOSE, + + /** + * 子流程组件 + */ PIPELINE, + + /** + * 适配器组件 + */ ADAPTER, } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/component/Component.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/component/Component.java index f874be3..0493f12 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/component/Component.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/component/Component.java @@ -132,9 +132,9 @@ public abstract class Component implements Rollback, Describable, Va } - /* Visit component's structure */ + /** Visit component's structure */ public abstract void visit(ComponentVisitor visitor); - /* Returns component's type */ + /** Returns component's type */ public abstract ComponentType getType(); } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/exception/ExceptionHandler.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/exception/ExceptionHandler.java index 7e9b568..47f6403 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/exception/ExceptionHandler.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/exception/ExceptionHandler.java @@ -9,5 +9,13 @@ import org.smartboot.flow.core.EngineContext; */ public interface ExceptionHandler { + /** + * 处理异常 + * + * @param context 执行上下文 + * @param e 抛出的异常 + * @param 入参泛型 + * @param 出参泛型 + */ void handle(EngineContext context, Throwable e); } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/executable/AbstractExecutable.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/executable/AbstractExecutable.java index 9e3f8b7..94007aa 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/executable/AbstractExecutable.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/executable/AbstractExecutable.java @@ -12,6 +12,7 @@ import org.smartboot.flow.core.EngineContext; */ public abstract class AbstractExecutable implements Executable { + @Override public void execute(EngineContext context) { this.execute(context.getReq(), context.getResult()); } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/executable/Executable.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/executable/Executable.java index 3ee6800..046121c 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/executable/Executable.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/executable/Executable.java @@ -14,5 +14,10 @@ import org.smartboot.flow.core.Rollback; */ public interface Executable extends Rollback, Describable { + /** + * 业务逻辑执行 + * + * @param context 执行上下文 + */ void execute(EngineContext context); } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/executable/ExecutableAdapter.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/executable/ExecutableAdapter.java index b22dc9c..e11d123 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/executable/ExecutableAdapter.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/executable/ExecutableAdapter.java @@ -30,6 +30,7 @@ public class ExecutableAdapter extends Component implements Rollback< this.executable = executable; } + @Override public int invoke(EngineContext context) { context.enter(this); diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/invoker/InvokeListener.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/invoker/InvokeListener.java index 545f461..408c1da 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/invoker/InvokeListener.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/invoker/InvokeListener.java @@ -10,5 +10,13 @@ import org.smartboot.flow.core.component.Component; */ public interface InvokeListener { + /** + * 执行完毕后通知处理 + * + * @param component 执行的组件 + * @param context 执行上下文 + * @param 入参泛型 + * @param 出参泛型 + */ void onCompleted(Component component, EngineContext context); } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/ComponentModel.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/ComponentModel.java index fc5f7b7..d5de986 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/ComponentModel.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/ComponentModel.java @@ -27,9 +27,7 @@ public class ComponentModel extends Uniqueness { private final Map components = new ConcurrentHashMap<>(); String executable; - // basic, if, choose, pipeline; ComponentType type; - // Used with type pipeline. PipelineModel pipeline; String condition; private String branch; @@ -84,11 +82,11 @@ public class ComponentModel extends Uniqueness { collected.put(this.identifier, this); return collected; } else if (type == ComponentType.BASIC) { - Map temp = new HashMap<>(); + Map temp = new HashMap<>(4); temp.put(this.identifier, this); return temp; } else { - Map temp = new HashMap<>(); + Map temp = new HashMap<>(8); this.components.forEach((k, v) -> temp.putAll(v.collect())); temp.put(this.identifier, this); return temp; diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisterEngineVisitor.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisterEngineVisitor.java index 66da81b..a69ccc7 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisterEngineVisitor.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisterEngineVisitor.java @@ -1,7 +1,7 @@ package org.smartboot.flow.core.manager; import org.smartboot.flow.core.FlowEngine; -import org.smartboot.flow.core.util.ContactUtils; +import org.smartboot.flow.core.util.AuxiliaryUtils; import org.smartboot.flow.core.visitor.EngineVisitor; import org.smartboot.flow.core.visitor.PipelineVisitor; @@ -33,7 +33,7 @@ public class RegisterEngineVisitor extends EngineVisitor { @Override public PipelineVisitor visitPipeline(String pipeline) { - PipelineModel pipelineModel = new PipelineModel(pipeline, ContactUtils.contact(this.model.getIdentifier(), pipeline)); + PipelineModel pipelineModel = new PipelineModel(pipeline, AuxiliaryUtils.contact(this.model.getIdentifier(), pipeline)); this.model.setPipeline(pipelineModel); return new RegisteredPipelineVisitor(pipelineModel, visited); } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredComponentVisitor.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredComponentVisitor.java index bd615e0..1ea130f 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredComponentVisitor.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredComponentVisitor.java @@ -3,7 +3,6 @@ package org.smartboot.flow.core.manager; import org.smartboot.flow.core.common.ComponentType; import org.smartboot.flow.core.attribute.AttributeHolder; import org.smartboot.flow.core.component.Component; -import org.smartboot.flow.core.util.AuxiliaryUtils; import org.smartboot.flow.core.util.ContactUtils; import org.smartboot.flow.core.visitor.ComponentVisitor; import org.smartboot.flow.core.visitor.ConditionVisitor; diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredPipelineVisitor.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredPipelineVisitor.java index d2e25ee..6572eff 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredPipelineVisitor.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredPipelineVisitor.java @@ -3,7 +3,6 @@ package org.smartboot.flow.core.manager; import org.smartboot.flow.core.Pipeline; import org.smartboot.flow.core.common.ComponentType; import org.smartboot.flow.core.util.AuxiliaryUtils; -import org.smartboot.flow.core.util.ContactUtils; import org.smartboot.flow.core.visitor.ComponentVisitor; import org.smartboot.flow.core.visitor.PipelineVisitor; @@ -38,7 +37,7 @@ public class RegisteredPipelineVisitor extends PipelineVisitor { return null; } - ComponentModel comp = new ComponentModel(type, ContactUtils.contact(this.pipelineModel.getIdentifier(), AuxiliaryUtils.or(name, describe))); + ComponentModel comp = new ComponentModel(type, AuxiliaryUtils.contact(this.pipelineModel.getIdentifier(), AuxiliaryUtils.or(name, describe))); this.pipelineModel.addComponent(comp); return new RegisteredComponentVisitor(comp, visited); } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/metrics/MetricExecutionListener.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/metrics/MetricExecutionListener.java index 550acc4..8eb1fd5 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/metrics/MetricExecutionListener.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/metrics/MetricExecutionListener.java @@ -36,7 +36,7 @@ public class MetricExecutionListener extends ExecutionListenerSupport { Map escaped = context.getExt(Key.of(this)); if (escaped == null) { - escaped = new ConcurrentHashMap<>(); + escaped = new ConcurrentHashMap<>(32); context.putExt(Key.of(this), escaped); } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/metrics/MetricKind.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/metrics/MetricKind.java index c2f80b8..921b016 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/metrics/MetricKind.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/metrics/MetricKind.java @@ -7,7 +7,13 @@ package org.smartboot.flow.core.metrics; */ public enum MetricKind { + /** + * 累加 + */ ACCUMULATE, + /** + * 最大 + */ MAX, } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/BuilderDefinitionVisitor.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/BuilderDefinitionVisitor.java index 044d0ff..7cb1386 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/BuilderDefinitionVisitor.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/BuilderDefinitionVisitor.java @@ -275,9 +275,16 @@ public class BuilderDefinitionVisitor implements DefinitionVisitor { return new ArrayList<>(namedEngines.keySet()); } - @SuppressWarnings("unchecked") public FlowEngine getEngine(String name) { EngineBuilder engineBuilder = namedEngines.get(name); return (FlowEngine)engineBuilder.build(); } + + /** + * Pipeline组装后置通知 + */ + public interface PipelineEndCallBack { + + void execute(Pipeline pipeline); + } } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/DefaultParser.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/DefaultParser.java index f13acfa..dbdfdf0 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/DefaultParser.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/DefaultParser.java @@ -126,7 +126,7 @@ public class DefaultParser implements Parser { public Map> getEngines() { List engineNames = visitor.getEngineNames(); - Map> engines = new HashMap<>(); + Map> engines = new HashMap<>(engineNames.size()); for (String name : engineNames) { engines.put(name, getEngine(name)); } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/ParserContext.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/ParserContext.java index d15e1ed..6c219e4 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/ParserContext.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/ParserContext.java @@ -34,7 +34,7 @@ public class ParserContext { */ private final ElementParserRegistry parserRegistry = ElementParserRegistry.getInstance(); - /* Registered Element definitions */ + /** Registered Element definitions */ private final Map registered = new ConcurrentHashMap<>(); private final Map generatedIdentifiers = new ConcurrentHashMap<>(); private IdentifierManager identifierManager = new DefaultIdentifierManager(); diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/PipelineEndCallBack.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/PipelineEndCallBack.java deleted file mode 100644 index f663127..0000000 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/PipelineEndCallBack.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.smartboot.flow.core.parser; - -import org.smartboot.flow.core.Pipeline; - -/** - * @author qinluo - * @date 2022-11-16 17:19:03 - * @since 1.0.0 - */ -public interface PipelineEndCallBack { - - void execute(Pipeline pipeline); -} diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptCondition.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptCondition.java index 31a858e..f18908e 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptCondition.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptCondition.java @@ -41,6 +41,12 @@ public abstract class ScriptCondition extends NamedCondition { return null; } + /** + * 执行条件表达式 + * + * @param context 当前执行上下文 + * @return 执行结果 + */ @Override public abstract Object test(EngineContext context); diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptVariableManager.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptVariableManager.java index d6199cb..dc8d628 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptVariableManager.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/script/ScriptVariableManager.java @@ -35,7 +35,7 @@ public class ScriptVariableManager { } public synchronized static void register(String engine, String key, Object variable) { - Map variables = ENGINE_VARIABLES.getOrDefault(engine, new ConcurrentHashMap<>()); + Map variables = ENGINE_VARIABLES.getOrDefault(engine, new ConcurrentHashMap<>(4)); variables.put(key, variable); ENGINE_VARIABLES.put(engine, variables); } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/trace/Node.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/trace/Node.java index 243deb2..031c837 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/trace/Node.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/trace/Node.java @@ -1,5 +1,7 @@ package org.smartboot.flow.core.trace; +import org.smartboot.flow.core.EngineConstants; + import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -119,7 +121,7 @@ public class Node { return "|---"; } - if (prefix.length() == 4) { + if (prefix.length() == EngineConstants.TAB_SIZE) { return (hasNext ? "|" : " ") + " |" + (async ? "~~~" : "---"); } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/util/AuxiliaryUtils.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/util/AuxiliaryUtils.java index 1b21359..8ba3a4b 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/util/AuxiliaryUtils.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/util/AuxiliaryUtils.java @@ -45,4 +45,15 @@ public final class AuxiliaryUtils { sb.append("\t"); } } + + public static String contact(String p, Object ...s) { + StringBuilder sb = new StringBuilder(); + sb.append(p); + + for (Object suffix : s) { + sb.append("-").append(suffix); + } + + return sb.toString(); + } } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/util/ContactUtils.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/util/ContactUtils.java deleted file mode 100644 index e197918..0000000 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/util/ContactUtils.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.smartboot.flow.core.util; - -/** - * @author qinluo - * @date 2022/11/20 22:10 - * @since 1.0.0 - */ -public final class ContactUtils { - - public static String contact(String p, Object ...s) { - StringBuilder sb = new StringBuilder(); - sb.append(p); - - for (Object suffix : s) { - sb.append("-").append(suffix); - } - - return sb.toString(); - } -} diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/visitor/ConditionVisitor.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/visitor/ConditionVisitor.java index 5723643..7ba836b 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/visitor/ConditionVisitor.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/visitor/ConditionVisitor.java @@ -20,7 +20,7 @@ public class ConditionVisitor { } /** - * Visit pipeline source. + * Visit condition source. */ public void visitSource(Condition condition) { if (delegate != null) { diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/Color.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/Color.java similarity index 94% rename from smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/Color.java rename to smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/Color.java index f028cf5..22b7285 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/Color.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/Color.java @@ -1,4 +1,4 @@ -package org.smartboot.flow.core.view.plantuml; +package org.smartboot.flow.helper.view; /** * @author qinluo diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/PlantumlComponent.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/PlantumlComponent.java similarity index 97% rename from smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/PlantumlComponent.java rename to smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/PlantumlComponent.java index f4504b6..1e2c069 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/PlantumlComponent.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/PlantumlComponent.java @@ -1,4 +1,4 @@ -package org.smartboot.flow.core.view.plantuml; +package org.smartboot.flow.helper.view; import org.smartboot.flow.core.common.ComponentType; import org.smartboot.flow.core.attribute.AttributeHolder; @@ -21,9 +21,7 @@ public class PlantumlComponent extends ComponentVisitor { private final List attributes = new ArrayList<>(); private final String name; private final String describe; - // basic, if, choose, pipeline; private final ComponentType type; - // Used with type pipeline. private PlantumlPipeline pipeline; private String condition; private String branch; @@ -95,7 +93,7 @@ public class PlantumlComponent extends ComponentVisitor { } content.append("if (").append(condition).append(") then (true)\n"); components.get(0).generate(content); - if (components.size() >= 2) { + if (components.size() > 1) { content.append("else (false)\n"); components.get(1).generate(content); } diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/PlantumlEngineVisitor.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/PlantumlEngineVisitor.java similarity index 97% rename from smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/PlantumlEngineVisitor.java rename to smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/PlantumlEngineVisitor.java index 5413c8a..ebb55e1 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/PlantumlEngineVisitor.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/PlantumlEngineVisitor.java @@ -1,4 +1,4 @@ -package org.smartboot.flow.core.view.plantuml; +package org.smartboot.flow.helper.view; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,7 +27,7 @@ public class PlantumlEngineVisitor extends EngineVisitor { private static final String END = "@enduml"; private static final String SUFFIX = ".puml"; - // plantuml file dest. + /** plantuml file dest. */ private final String dest; /** * engine name. diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/PlantumlPipeline.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/PlantumlPipeline.java similarity index 97% rename from smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/PlantumlPipeline.java rename to smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/PlantumlPipeline.java index 76dced6..193cf8b 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/view/plantuml/PlantumlPipeline.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/PlantumlPipeline.java @@ -1,4 +1,4 @@ -package org.smartboot.flow.core.view.plantuml; +package org.smartboot.flow.helper.view; import org.smartboot.flow.core.Pipeline; import org.smartboot.flow.core.common.ComponentType; diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java index 8b5b748..9d1d4af 100644 --- a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlComponentVisitor.java @@ -19,9 +19,7 @@ import java.util.Set; public class XmlComponentVisitor extends ComponentVisitor { private final List attributes = new ArrayList<>(); - // basic, if, choose, pipeline; private final ComponentType type; - // Used with type pipeline. private XmlPipelineVisitor pipeline; private String condition; private String branch; @@ -105,7 +103,7 @@ public class XmlComponentVisitor extends ComponentVisitor { AuxiliaryUtils.appendTab(content, numbersOfTab + 1); content.append("\n"); - if (components.size() >= 2) { + if (components.size() > 1) { AuxiliaryUtils.appendTab(content, numbersOfTab + 1); content.append("\n"); components.get(1).generate(content, numbersOfTab + 2); diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java index b1cc8d0..c44021a 100644 --- a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/XmlPipelineVisitor.java @@ -1,5 +1,6 @@ package org.smartboot.flow.helper.view; +import org.smartboot.flow.core.EngineConstants; import org.smartboot.flow.core.Pipeline; import org.smartboot.flow.core.common.ComponentType; import org.smartboot.flow.core.util.AuxiliaryUtils; @@ -58,7 +59,7 @@ public class XmlPipelineVisitor extends PipelineVisitor { // for anonymous-pipeline boolean incrementTab = false; // - if (name != null && !name.contains("anonymous-pipeline")) { + if (name != null && !name.contains(EngineConstants.ANONYMOUS_PREFIX)) { incrementTab = true; AuxiliaryUtils.appendTab(content, numbersOfTab); content.append("\n"); @@ -68,7 +69,7 @@ public class XmlPipelineVisitor extends PipelineVisitor { component.generate(content, incrementTab ? numbersOfTab + 1 : numbersOfTab); } - if (name != null && !name.contains("anonymous-pipeline")) { + if (name != null && !name.contains(EngineConstants.ANONYMOUS_PREFIX)) { AuxiliaryUtils.appendTab(content, numbersOfTab); content.append("\n"); } diff --git a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerConstants.java b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerConstants.java new file mode 100644 index 0000000..7bed422 --- /dev/null +++ b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerConstants.java @@ -0,0 +1,14 @@ +package org.smartboot.flow.manager; + +/** + * @author qinluo + * @date 2023/2/1 21:56 + * @since 1.0.0 + */ +public interface ManagerConstants { + + /** + * Http success code. + */ + int SUCCESS = 200; +} diff --git a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerExecutionListener.java b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerExecutionListener.java index ea1122f..eb496b4 100644 --- a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerExecutionListener.java +++ b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerExecutionListener.java @@ -16,11 +16,11 @@ public class ManagerExecutionListener extends ExecutionListenerSupport { public void start(EngineContext context) { TraceIdGenerator generator = TraceIdGenerator.getTraceIdGenerator(); if (generator != null) { - context.putExt(ManagerKeys.traceId, generator.getTraceId(context)); + context.putExt(ManagerKeys.TRACE_ID, generator.getTraceId(context)); } // 暂时init个object - context.putExt(ManagerKeys.traces, new Object()); + context.putExt(ManagerKeys.TRACES, new Object()); } diff --git a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerKeys.java b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerKeys.java index 781e4ba..c36e689 100644 --- a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerKeys.java +++ b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/ManagerKeys.java @@ -12,13 +12,13 @@ public interface ManagerKeys { /** * TraceId key in engine ctx. */ - Key traceId = Key.of("traceId"); + Key TRACE_ID = Key.of("traceId"); /** * Invoke trace in engine invoking. * */ - Key traces = Key.of("traces"); + Key TRACES = Key.of("traces"); } diff --git a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/change/HttpManager.java b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/change/HttpManager.java index 609fbf9..7b3b5cb 100644 --- a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/change/HttpManager.java +++ b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/change/HttpManager.java @@ -7,6 +7,7 @@ import org.smartboot.flow.core.attribute.AttributeHolder; import org.smartboot.flow.core.attribute.Attributes; import org.smartboot.flow.core.manager.DefaultEngineManager; import org.smartboot.flow.core.util.AssertUtil; +import org.smartboot.flow.manager.ManagerConstants; import org.smartboot.flow.manager.NamedThreadFactory; import org.smartboot.flow.manager.reload.Reloader; import org.smartboot.flow.manager.report.HostUtils; @@ -93,7 +94,7 @@ public class HttpManager { post.bodyStream().write(bytes, 0, bytes.length); post.bodyStream().flush(); post.onSuccess(httpResponse -> { - if (httpResponse.getStatus() != 200) { + if (httpResponse.getStatus() != ManagerConstants.SUCCESS) { LOGGER.info("request remote address failed {}, code = {}", url, httpResponse.getStatus()); return; } diff --git a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/reload/ReloadListener.java b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/reload/ReloadListener.java index e41ada2..6588299 100644 --- a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/reload/ReloadListener.java +++ b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/reload/ReloadListener.java @@ -7,8 +7,21 @@ package org.smartboot.flow.manager.reload; */ public interface ReloadListener { - void onload(String engineName); + /** + * 引擎reload开始通知 + * + * @param engineName 引擎名称 + */ + default void onload(String engineName) { + + } + /** + * 引擎reload完成通知 + * + * @param engineName 引擎名称 + * @param e 异常信息,若成功,则为null + */ void loadCompleted(String engineName, Throwable e); /** diff --git a/smart-flow-script-condition/smart-flow-script-groovy/src/main/java/org/smartboot/flow/condition/extension/groovy/GroovyScriptCondition.java b/smart-flow-script-condition/smart-flow-script-groovy/src/main/java/org/smartboot/flow/condition/extension/groovy/GroovyScriptCondition.java index 83d2cfd..cf3967c 100644 --- a/smart-flow-script-condition/smart-flow-script-groovy/src/main/java/org/smartboot/flow/condition/extension/groovy/GroovyScriptCondition.java +++ b/smart-flow-script-condition/smart-flow-script-groovy/src/main/java/org/smartboot/flow/condition/extension/groovy/GroovyScriptCondition.java @@ -20,7 +20,7 @@ import java.util.Map; public class GroovyScriptCondition extends ScriptCondition { private static final Logger LOGGER = LoggerFactory.getLogger(GroovyScriptCondition.class); - private static final ScriptEngineManager engineManager = new ScriptEngineManager(); + private static final ScriptEngineManager MANAGER = new ScriptEngineManager(); protected String getScriptLang() { return "groovy"; @@ -29,7 +29,7 @@ public class GroovyScriptCondition extends ScriptCondition { @Override public Object test(EngineContext engineContext) { try { - ScriptEngine engine = engineManager.getEngineByName(getScriptLang()); + ScriptEngine engine = MANAGER.getEngineByName(getScriptLang()); Bindings data = engine.createBindings(); data.put(ScriptConstants.REQ, engineContext.getReq()); data.put(ScriptConstants.RESULT, engineContext.getResult()); diff --git a/smart-flow-script-condition/smart-flow-script-groovy/src/main/java/org/smartboot/flow/condition/extension/groovy/JavaScriptCondition.java b/smart-flow-script-condition/smart-flow-script-groovy/src/main/java/org/smartboot/flow/condition/extension/groovy/JavaScriptCondition.java index e8dfccd..a21e89b 100644 --- a/smart-flow-script-condition/smart-flow-script-groovy/src/main/java/org/smartboot/flow/condition/extension/groovy/JavaScriptCondition.java +++ b/smart-flow-script-condition/smart-flow-script-groovy/src/main/java/org/smartboot/flow/condition/extension/groovy/JavaScriptCondition.java @@ -7,6 +7,7 @@ package org.smartboot.flow.condition.extension.groovy; */ public class JavaScriptCondition extends GroovyScriptCondition { + @Override protected String getScriptLang() { return "javascript"; } diff --git a/smart-flow-script-condition/smart-flow-script-ognl/src/main/java/org/smartboot/flow/condition/extension/ognl/OgnlScriptCondition.java b/smart-flow-script-condition/smart-flow-script-ognl/src/main/java/org/smartboot/flow/condition/extension/ognl/OgnlScriptCondition.java index bf70ddb..55dded9 100644 --- a/smart-flow-script-condition/smart-flow-script-ognl/src/main/java/org/smartboot/flow/condition/extension/ognl/OgnlScriptCondition.java +++ b/smart-flow-script-condition/smart-flow-script-ognl/src/main/java/org/smartboot/flow/condition/extension/ognl/OgnlScriptCondition.java @@ -23,7 +23,7 @@ public class OgnlScriptCondition extends ScriptCondition { @Override public Object test(EngineContext engineContext) { try { - Map context = new HashMap<>(); + Map context = new HashMap<>(8); context.put(ScriptConstants.REQ, engineContext.getReq()); context.put(ScriptConstants.RESULT, engineContext.getResult()); context.put(ScriptConstants.CONTEXT, engineContext); diff --git a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/BeanDefinitionRegister.java b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/BeanDefinitionRegister.java index ae84494..fa0b792 100644 --- a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/BeanDefinitionRegister.java +++ b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/BeanDefinitionRegister.java @@ -40,8 +40,4 @@ public class BeanDefinitionRegister { registered.put(identifier, def); } } - - public boolean containsBeanDefinition(String identifier) { - return registered.containsKey(identifier) || registry.containsBeanDefinition(identifier); - } } diff --git a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NameAwareCondition.java b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NameAwareCondition.java index 6f753bf..802c24f 100644 --- a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NameAwareCondition.java +++ b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NameAwareCondition.java @@ -10,7 +10,6 @@ import org.springframework.beans.factory.BeanNameAware; */ public abstract class NameAwareCondition extends NamedCondition implements BeanNameAware { - @SuppressWarnings("NullableProblems") @Override public void setBeanName(String name) { super.setName(name); diff --git a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NamedAbstractExecutable.java b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NamedAbstractExecutable.java index 17783f5..9f140de 100644 --- a/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NamedAbstractExecutable.java +++ b/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/NamedAbstractExecutable.java @@ -12,7 +12,6 @@ public abstract class NamedAbstractExecutable extends AbstractExecutable Date: Wed, 1 Feb 2023 22:13:18 +0800 Subject: [PATCH 17/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../smartboot/flow/core/DefaultIdentifierManager.java | 6 +++--- .../flow/core/manager/RegisteredComponentVisitor.java | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/DefaultIdentifierManager.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/DefaultIdentifierManager.java index 92a75c4..f15a632 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/DefaultIdentifierManager.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/DefaultIdentifierManager.java @@ -1,6 +1,6 @@ package org.smartboot.flow.core; -import org.smartboot.flow.core.util.ContactUtils; +import org.smartboot.flow.core.util.AuxiliaryUtils; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -21,11 +21,11 @@ public class DefaultIdentifierManager implements IdentifierManager { @Override public String generateIdentifier(String prefix) { - String identifier = ContactUtils.contact(prefix, sequence.getAndAdd(1)); + String identifier = AuxiliaryUtils.contact(prefix, sequence.getAndAdd(1)); // Ensure identifier is unique. while (identifiers.containsKey(identifier) || identifiers.put(identifier, 1) != null) { - identifier = ContactUtils.contact(prefix, sequence.getAndAdd(1)); + identifier = AuxiliaryUtils.contact(prefix, sequence.getAndAdd(1)); } return identifier; diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredComponentVisitor.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredComponentVisitor.java index 1ea130f..d664ac4 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredComponentVisitor.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/manager/RegisteredComponentVisitor.java @@ -3,7 +3,7 @@ package org.smartboot.flow.core.manager; import org.smartboot.flow.core.common.ComponentType; import org.smartboot.flow.core.attribute.AttributeHolder; import org.smartboot.flow.core.component.Component; -import org.smartboot.flow.core.util.ContactUtils; +import org.smartboot.flow.core.util.AuxiliaryUtils; import org.smartboot.flow.core.visitor.ComponentVisitor; import org.smartboot.flow.core.visitor.ConditionVisitor; import org.smartboot.flow.core.visitor.PipelineVisitor; @@ -28,7 +28,7 @@ public class RegisteredComponentVisitor extends ComponentVisitor { @Override public PipelineVisitor visitPipeline(String pipeline) { - PipelineModel pipelineModel = new PipelineModel(pipeline, ContactUtils.contact(model.getIdentifier(), pipeline)); + PipelineModel pipelineModel = new PipelineModel(pipeline, AuxiliaryUtils.contact(model.getIdentifier(), pipeline)); this.model.pipeline = pipelineModel; return new RegisteredPipelineVisitor(pipelineModel, visited); } @@ -46,10 +46,10 @@ public class RegisteredComponentVisitor extends ComponentVisitor { @Override public ComponentVisitor visitComponent(ComponentType type, String name, String describe) { - String identifier = ContactUtils.contact(model.getIdentifier(), AuxiliaryUtils.or(name, describe)); + String identifier = AuxiliaryUtils.contact(model.getIdentifier(), AuxiliaryUtils.or(name, describe)); String branch = null; if (this.model.type == ComponentType.CHOOSE) { - identifier = ContactUtils.contact(model.getIdentifier(), "default"); + identifier = AuxiliaryUtils.contact(model.getIdentifier(), "default"); branch = "default"; } @@ -66,7 +66,7 @@ public class RegisteredComponentVisitor extends ComponentVisitor { @Override public ComponentVisitor visitBranch(Object branch, ComponentType type, String name, String describe) { - ComponentModel model = new ComponentModel(type, ContactUtils.contact(this.model.getIdentifier(), "branch", String.valueOf(branch))); + ComponentModel model = new ComponentModel(type, AuxiliaryUtils.contact(this.model.getIdentifier(), "branch", String.valueOf(branch))); model.setBranch((String.valueOf(branch))); this.model.addComponent(model); return new RegisteredComponentVisitor(model, visited); -- Gitee From 2d11452324ea3fafc2228b4535f975e037e9ffdc Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Wed, 1 Feb 2023 22:24:32 +0800 Subject: [PATCH 18/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/smartboot/flow/core/FlowEngine.java | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java index 464b20b..42be7b2 100644 --- a/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java +++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/FlowEngine.java @@ -10,8 +10,6 @@ import org.smartboot.flow.core.util.AssertUtil; import org.smartboot.flow.core.visitor.EngineVisitor; import org.smartboot.flow.core.visitor.PipelineVisitor; -import java.util.HashMap; -import java.util.Map; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; @@ -34,13 +32,6 @@ public class FlowEngine implements Describable, Validator, Measurable { */ private final long startedAt = System.currentTimeMillis(); - /** - * Extension attributes. - * - * @since 1.0.5 - */ - private Map attributes = new HashMap<>(); - /** Used in async invoking */ private ExecutorService executor; @@ -143,18 +134,6 @@ public class FlowEngine implements Describable, Validator, Measurable { this.executor = executor; } - public String getAttribute(String key) { - return this.attributes.get(key); - } - - public void addAttribute(String key, String value) { - this.attributes.put(key, value); - } - - public void setAttributes(Map attributes) { - this.attributes = attributes; - } - /** * Return flow-engine created timestamp. * -- Gitee From 9a60f1e585dbf15b3fc358bf90a61277baeb1ba4 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Wed, 1 Feb 2023 22:27:21 +0800 Subject: [PATCH 19/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4init.sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/init.sql | 56 ------------------- 1 file changed, 56 deletions(-) delete mode 100644 smart-flow-manager/src/main/resources/init.sql diff --git a/smart-flow-manager/src/main/resources/init.sql b/smart-flow-manager/src/main/resources/init.sql deleted file mode 100644 index 1609f51..0000000 --- a/smart-flow-manager/src/main/resources/init.sql +++ /dev/null @@ -1,56 +0,0 @@ --- 引擎表 -CREATE TABLE `engine_table` ( - `id` bigint NOT NULL AUTO_INCREMENT, - `engine_name` varchar(256) NOT NULL COMMENT '引擎名称,唯一', - `content` text COMMENT '引擎配置内容,必须是xml形式', - `version` int NOT NULL DEFAULT '1' COMMENT '版本', - `status` int NOT NULL DEFAULT '0' COMMENT '状态 0-正常 1-删除', - `created` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updated` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - PRIMARY KEY (`id`), - UNIQUE KEY `uk_engine_name` (`engine_name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='引擎配置表'; - --- 引擎历史表 -CREATE TABLE `engine_table_history` ( - `id` bigint NOT NULL AUTO_INCREMENT, - `engine_id` bigint NOT NULL COMMENT '引擎id', - `engine_name` varchar(256) NOT NULL COMMENT '引擎名称', - `content` text COMMENT '引擎配置内容,必须是xml形式', - `version` int NOT NULL DEFAULT '1' COMMENT '版本', - `created` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updated` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - PRIMARY KEY (`id`), -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='引擎历史记录表' - --- 引擎结构快照 -CREATE TABLE `engine_table_snapshot` ( - `id` bigint NOT NULL AUTO_INCREMENT, - `engine_name` varchar(256) NOT NULL COMMENT '引擎名称', - `content` text COMMENT '引擎配置内容,必须是xml形式', - `md5` varchar(256) COMMENT 'content md5加密字符串', - `created` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updated` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - PRIMARY KEY (`id`), - UNIQUE KEY `uk_md5` (`md5`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='引擎快照表' - --- 执行耗时 -CREATE TABLE `engine_table_metrics` ( - `id` bigint NOT NULL AUTO_INCREMENT, - `engine_name` varchar(256) NOT NULL COMMENT '引擎名称', - `content` text COMMENT 'json格式', - `created` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updated` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - PRIMARY KEY (`id`), -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='引擎执行数据表' - --- 执行trace -CREATE TABLE `engine_table_trace` ( - `id` bigint NOT NULL AUTO_INCREMENT, - `engine_name` varchar(256) NOT NULL COMMENT '引擎名称', - `content` text COMMENT 'json格式', - `created` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updated` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - PRIMARY KEY (`id`), -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='引擎执行链路表' \ No newline at end of file -- Gitee From 4884fb3728001b79de6a3d0f102b902c51ae5b26 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Wed, 1 Feb 2023 22:34:13 +0800 Subject: [PATCH 20/20] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E5=8D=87?= =?UTF-8?q?=E7=BA=A7v1.0.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- smart-flow-core/pom.xml | 2 +- smart-flow-helper/pom.xml | 4 ++-- smart-flow-manager/pom.xml | 6 +++--- smart-flow-script-condition/pom.xml | 4 ++-- .../smart-flow-script-groovy/pom.xml | 2 +- smart-flow-script-condition/smart-flow-script-ognl/pom.xml | 2 +- .../smart-flow-script-qlexpress/pom.xml | 2 +- smart-flow-spring-extension/pom.xml | 4 ++-- smart-flow-springboot-starter/pom.xml | 4 ++-- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index a73fe4f..ffed0a3 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.smartboot.flow smart-flow-parent - 1.0.5-SNAPSHOT + 1.0.5 4.0.0 pom smart-flow diff --git a/smart-flow-core/pom.xml b/smart-flow-core/pom.xml index 98bd2ce..80d45ac 100644 --- a/smart-flow-core/pom.xml +++ b/smart-flow-core/pom.xml @@ -5,7 +5,7 @@ org.smartboot.flow smart-flow-parent - 1.0.5-SNAPSHOT + 1.0.5 4.0.0 diff --git a/smart-flow-helper/pom.xml b/smart-flow-helper/pom.xml index 3653215..c13f06e 100644 --- a/smart-flow-helper/pom.xml +++ b/smart-flow-helper/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.5-SNAPSHOT + 1.0.5 4.0.0 @@ -20,7 +20,7 @@ org.smartboot.flow smart-flow-core - 1.0.5-SNAPSHOT + 1.0.5 diff --git a/smart-flow-manager/pom.xml b/smart-flow-manager/pom.xml index c3ee046..a46b1c0 100644 --- a/smart-flow-manager/pom.xml +++ b/smart-flow-manager/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.5-SNAPSHOT + 1.0.5 4.0.0 @@ -20,13 +20,13 @@ org.smartboot.flow smart-flow-core - 1.0.5-SNAPSHOT + 1.0.5 org.smartboot.flow smart-flow-helper - 1.0.5-SNAPSHOT + 1.0.5 diff --git a/smart-flow-script-condition/pom.xml b/smart-flow-script-condition/pom.xml index 84b170b..61a52f2 100644 --- a/smart-flow-script-condition/pom.xml +++ b/smart-flow-script-condition/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.5-SNAPSHOT + 1.0.5 4.0.0 pom @@ -27,7 +27,7 @@ org.smartboot.flow smart-flow-core - 1.0.5-SNAPSHOT + 1.0.5 diff --git a/smart-flow-script-condition/smart-flow-script-groovy/pom.xml b/smart-flow-script-condition/smart-flow-script-groovy/pom.xml index f2a16f6..28e2a86 100644 --- a/smart-flow-script-condition/smart-flow-script-groovy/pom.xml +++ b/smart-flow-script-condition/smart-flow-script-groovy/pom.xml @@ -5,7 +5,7 @@ smart-flow-script-condition org.smartboot.flow - 1.0.5-SNAPSHOT + 1.0.5 4.0.0 diff --git a/smart-flow-script-condition/smart-flow-script-ognl/pom.xml b/smart-flow-script-condition/smart-flow-script-ognl/pom.xml index 94d83ab..6191fa7 100644 --- a/smart-flow-script-condition/smart-flow-script-ognl/pom.xml +++ b/smart-flow-script-condition/smart-flow-script-ognl/pom.xml @@ -5,7 +5,7 @@ smart-flow-script-condition org.smartboot.flow - 1.0.5-SNAPSHOT + 1.0.5 4.0.0 diff --git a/smart-flow-script-condition/smart-flow-script-qlexpress/pom.xml b/smart-flow-script-condition/smart-flow-script-qlexpress/pom.xml index cbca1b6..434f206 100644 --- a/smart-flow-script-condition/smart-flow-script-qlexpress/pom.xml +++ b/smart-flow-script-condition/smart-flow-script-qlexpress/pom.xml @@ -5,7 +5,7 @@ smart-flow-script-condition org.smartboot.flow - 1.0.5-SNAPSHOT + 1.0.5 4.0.0 diff --git a/smart-flow-spring-extension/pom.xml b/smart-flow-spring-extension/pom.xml index 0d06ca6..e5cb0f6 100644 --- a/smart-flow-spring-extension/pom.xml +++ b/smart-flow-spring-extension/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.5-SNAPSHOT + 1.0.5 4.0.0 @@ -22,7 +22,7 @@ org.smartboot.flow smart-flow-manager - 1.0.5-SNAPSHOT + 1.0.5 diff --git a/smart-flow-springboot-starter/pom.xml b/smart-flow-springboot-starter/pom.xml index 365a1c6..dcc77cc 100644 --- a/smart-flow-springboot-starter/pom.xml +++ b/smart-flow-springboot-starter/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.5-SNAPSHOT + 1.0.5 4.0.0 @@ -25,7 +25,7 @@ org.smartboot.flow smart-flow-spring-extension - 1.0.5-SNAPSHOT + 1.0.5 -- Gitee