subcollected = model.collect();
+ if (subcollected != null) {
+ collected.putAll(subcollected);
+ }
collected.put(model.getIdentifier(), model);
}
diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/ParseHelper.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/ParseHelper.java
new file mode 100644
index 0000000000000000000000000000000000000000..bda819d04f4b8a16f33ec24d2f688e34f9a31a1c
--- /dev/null
+++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/parser/ParseHelper.java
@@ -0,0 +1,174 @@
+package org.smartboot.flow.core.parser;
+
+import org.smartboot.flow.core.FlowEngine;
+import org.smartboot.flow.core.attribute.AttributeValueResolver;
+import org.smartboot.flow.core.util.AssertUtil;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 更便捷的解析入口
+ *
+ *
+ * {@code
+ *
+ * try {
+ * DefaultParser parser = new DefaultParser();
+ * parser.parse(this.getClass().getResourceAsStream("/engine.xml");
+ * FlowEngine engine = parser.get("testEngine");
+ * } catch (Exception e) {
+ *
+ * }
+ * }
+ *
+ *
+ * 可以简化为如下代码
+ *
+ * {@code
+ * FlowEngine engine
+ * = ParseHelper.classpath("engine.xml").get("testEngine");
+ *
+ * }
+ *
+ *
+ * 或者(仅有一个引擎的情况下)
+ *
+ * {@code
+ * FlowEngine engine
+ * = ParseHelper.classpath("engine.xml").unique();
+ *
+ * }
+ *
+ *
+ * 当然也提供方法支持多个配置文件以及自定义解析器
+ *
+ * @author qinluo
+ * @date 2023-10-26 15:00:41
+ * @since 1.1.4
+ */
+public final class ParseHelper {
+
+ private static final int classpath = 1;
+ private static final int absolute = 2;
+ private static final int relative = 3;
+
+ public static ParseHelperBuilder classpath(String config) {
+ return new ParseHelperBuilder(config, classpath);
+ }
+
+ public static ParseHelperBuilder absolute(String config) {
+ return new ParseHelperBuilder(config, absolute);
+ }
+
+ public static ParseHelperBuilder relative(String config) {
+ return new ParseHelperBuilder(config, relative);
+ }
+
+ static InputStream getResource(String config, int type) {
+ try {
+ if (type == classpath) {
+ return ParseHelper.class.getResourceAsStream(config);
+ } else if (type == absolute || type == relative) {
+ return new FileInputStream(config);
+ }
+ } catch (Exception ignored) {
+
+ }
+
+ return null;
+ }
+
+ public static class ParseHelperBuilder {
+ private final List streams = new ArrayList<>(0);
+ private final int type;
+ private boolean completed;
+ private final DefaultParser parser = new DefaultParser();
+ private final InputStream mainStream;
+
+ ParseHelperBuilder(String config, int type) {
+ this.type = type;
+ AssertUtil.notBlank(config, "config must not be blank");
+
+ InputStream stream = getResource(config, type);
+ AssertUtil.notNull(stream, "config " + config + " cannot found.");
+ this.mainStream = stream;
+ }
+
+ private void addStream(String config, int type) {
+ InputStream stream = getResource(config, type);
+ AssertUtil.notNull(stream, "config " + config + " cannot found.");
+ this.streams.add(stream);
+ }
+
+ private void processParse() {
+ if (!completed) {
+ parser.parse(mainStream, streams.toArray(new InputStream[0]));
+ }
+ completed = true;
+ }
+
+ /* Engine scene. */
+
+ public FlowEngine unique() {
+ processParse();
+ AssertUtil.isTrue(parser.getEngines().size() == 1, "Multiple engines.");
+ List engineNames = parser.getEngineNames();
+ return parser.getEngine(engineNames.get(0));
+ }
+
+ public FlowEngine first() {
+ processParse();
+ List engineNames = parser.getEngineNames();
+ if (engineNames.size() > 0) {
+ return parser.getEngine(engineNames.get(0));
+ }
+ return null;
+ }
+
+ public FlowEngine get(String name) {
+ processParse();
+ return parser.getEngine(name);
+ }
+
+
+ /* Customized Parser scene methods */
+ public ParseHelperBuilder withObjectCreator(ObjectCreator creator) {
+ this.parser.setObjectCreator(creator);
+ return this;
+ }
+
+ public ParseHelperBuilder withResolver(AttributeValueResolver resolver) {
+ this.parser.setAttributeValueResolver(resolver);
+ return this;
+ }
+
+ public ParseHelperBuilder withScriptLocations(String ...locations) {
+ this.parser.scriptLoader().locations(locations);
+ return this;
+ }
+
+ /* Special multiple config locations scene methods. */
+ public ParseHelperBuilder addConfig(String config) {
+ this.addStream(config, type);
+ return this;
+ }
+
+ public ParseHelperBuilder addClasspath(String config) {
+ this.addStream(config, classpath);
+ return this;
+ }
+
+ public ParseHelperBuilder addAbsolute(String config) {
+ this.addStream(config, absolute);
+ return this;
+ }
+
+ public ParseHelperBuilder addRelative(String config) {
+ this.addStream(config, relative);
+ return this;
+ }
+ }
+}
diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/util/BeanContext.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/util/BeanContext.java
index 84f616f7ff917a8d0ca6e04ed0fd580dff979868..8a77dfe9dd2bdb6249b02d78e03d208aae033dbe 100644
--- a/smart-flow-core/src/main/java/org/smartboot/flow/core/util/BeanContext.java
+++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/util/BeanContext.java
@@ -9,18 +9,43 @@ import java.util.List;
*/
public interface BeanContext {
+ /**
+ * Try to find a bean named name.
+ *
+ * @param name name.
+ * @param generic type
+ * @return bean
+ */
default T getBean(String name) {
throw new UnsupportedOperationException();
}
+ /**
+ * Try to find a specified type bean named name.
+ *
+ * @param name name.
+ * @param generic type
+ * @param type specified type
+ * @return bean
+ */
default T getBean(String name, Class type) {
throw new UnsupportedOperationException();
}
+ /**
+ * Try to find a specified type bean list.
+ *
+ * @param generic type
+ * @param type specified type
+ * @return bean list
+ */
default List getBean(Class type) {
throw new UnsupportedOperationException();
}
+ /**
+ * Make cur bean ctx enabled.
+ */
default void init() {
BeanUtils.init(this);
}
diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/util/BeanUtils.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/util/BeanUtils.java
index 0b8b6a9347d5f64a3ad18925f7f98cdf3f995f6f..8d1f3ebf1284e04b09741b01196fab9ae9e9bde2 100644
--- a/smart-flow-core/src/main/java/org/smartboot/flow/core/util/BeanUtils.java
+++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/util/BeanUtils.java
@@ -11,6 +11,17 @@ public class BeanUtils {
private static BeanContext instance = null;
+ /**
+ * Init bean context.
+ *
+ * @param ctx bean context
+ */
+ static void init(BeanContext ctx) {
+ instance = ctx;
+ }
+
+ /* Static delegate methods */
+
public static T getBean(String name) {
return instance.getBean(name);
}
@@ -23,9 +34,4 @@ public class BeanUtils {
List beans = instance.getBean(type);
return beans != null && beans.size() > 0 ? beans.get(0) : null;
}
-
- static void init(BeanContext ctx) {
- instance = ctx;
- }
-
}
diff --git a/smart-flow-core/src/main/resources/smart-flow-1.0.1.xsd b/smart-flow-core/src/main/resources/smart-flow-1.0.1.xsd
index 0e38d956dc1975be778066a070790cb97d6dc119..f42e80698a6a28b1bfee35ee5daa2c4df59c184e 100644
--- a/smart-flow-core/src/main/resources/smart-flow-1.0.1.xsd
+++ b/smart-flow-core/src/main/resources/smart-flow-1.0.1.xsd
@@ -36,6 +36,14 @@
+
+
+
+ 等待所有前置异步组件完成
+
+
+
+
@@ -61,6 +69,7 @@
+
diff --git a/smart-flow-helper/pom.xml b/smart-flow-helper/pom.xml
index 23c8f4e1c760b4dd74fa06001f50470ec9d8f56c..f59da36cdaed85e1abc657a6e3dc8ed4ba57ba42 100644
--- a/smart-flow-helper/pom.xml
+++ b/smart-flow-helper/pom.xml
@@ -5,7 +5,7 @@
smart-flow-parent
org.smartboot.flow
- 1.1.3
+ 1.1.4
4.0.0
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 d10a4fadc067eeea4f6f062218847591efdc7bb0..740ffe3fbffa664b9910e6a6d5b8b749b49551ea 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
@@ -36,6 +36,17 @@ public class XmlEngineVisitor extends EngineVisitor {
*/
private String content;
+ /**
+ * 是否替换反序列化文本中的换行符、tab等多余空白
+ *
+ * @since 1.1.4
+ */
+ private boolean compress;
+
+ public void compressContent() {
+ this.compress = true;
+ }
+
public String getContent() {
return content;
}
@@ -64,15 +75,29 @@ public class XmlEngineVisitor extends EngineVisitor {
unprocessed = PipelineCollector.getUnprocessed();
}
+ // Avoid process script.
+ if (compress) {
+ this.content = this.content.replace("\n", "")
+ .replace("\t", "").replace("\r\n", "");
+ }
+
Map> scripts = ScriptCollector.end();
if (scripts != null && scripts.size() > 0) {
- scripts.forEach((k, v) -> content.append("\n\t"));
+ .append("\">").append("").append("");
+ });
}
- content.append("\n").append(END).append("\n");
-
+ if (!compress) {
+ content.append("\n").append(END).append("\n");
+ } else {
+ content.append(END);
+ }
this.content = content.toString();
}
diff --git a/smart-flow-integration/pom.xml b/smart-flow-integration/pom.xml
index 4b1f46d90d0b929d53fb3c16c03138d54ff71454..e403b036f08a62fac3c6d9e6f2f4e36f5bec9e7b 100644
--- a/smart-flow-integration/pom.xml
+++ b/smart-flow-integration/pom.xml
@@ -5,7 +5,7 @@
smart-flow-parent
org.smartboot.flow
- 1.1.3
+ 1.1.4
4.0.0
diff --git a/smart-flow-integration/smart-flow-integration-nacos/pom.xml b/smart-flow-integration/smart-flow-integration-nacos/pom.xml
index aca264249e1dbfd88b7a77d242eb263518b3ad78..02a240bba480bfcddb513bd92f2f0c9106476d20 100644
--- a/smart-flow-integration/smart-flow-integration-nacos/pom.xml
+++ b/smart-flow-integration/smart-flow-integration-nacos/pom.xml
@@ -5,7 +5,7 @@
smart-flow-integration
org.smartboot.flow
- 1.1.3
+ 1.1.4
4.0.0
diff --git a/smart-flow-integration/smart-flow-spring-extension/pom.xml b/smart-flow-integration/smart-flow-spring-extension/pom.xml
index fb1a35e713cf17272a45522ee9621efb61b663d8..36ae61c9987d37c9b944fd23ee2b669a98077790 100644
--- a/smart-flow-integration/smart-flow-spring-extension/pom.xml
+++ b/smart-flow-integration/smart-flow-spring-extension/pom.xml
@@ -5,7 +5,7 @@
smart-flow-integration
org.smartboot.flow
- 1.1.3
+ 1.1.4
4.0.0
diff --git a/smart-flow-integration/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/BeanDefinitionVisitor.java b/smart-flow-integration/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/BeanDefinitionVisitor.java
index f1d9b80fdc2a0fcffdd7cbcde719388156b1b5b1..b733438e13a9c3dcc4ab5d1fab2d11f55fa573e7 100644
--- a/smart-flow-integration/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/BeanDefinitionVisitor.java
+++ b/smart-flow-integration/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/BeanDefinitionVisitor.java
@@ -173,6 +173,7 @@ public class BeanDefinitionVisitor implements DefinitionVisitor, BeanFactoryAwar
Attributes attribute = holder.getAttribute();
if (attribute == Attributes.NAME
|| attribute == Attributes.DEGRADE_CALLBACK
+ || attribute == Attributes.DEPENDS_ALL
|| !attribute.isVisible()) {
continue;
}
@@ -392,6 +393,10 @@ public class BeanDefinitionVisitor implements DefinitionVisitor, BeanFactoryAwar
PropertyValue name = new PropertyValue("name", ed.getName());
definition.setBeanClass(ed.resolveType());
definition.getPropertyValues().addPropertyValue(name);
+
+ if (ed instanceof ComponentDefinition) {
+ definition.getPropertyValues().add("valueResolver", new RuntimeBeanReference(SpringAttributeValueResolver.class.getName()));
+ }
return definition;
}
}
diff --git a/smart-flow-integration/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SmartFlowRegistrar.java b/smart-flow-integration/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SmartFlowRegistrar.java
index 58d17240732cb05b9e59c91250a2e5f4569482f1..91d9f368c921522ad94752183abe121de0679881 100644
--- a/smart-flow-integration/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SmartFlowRegistrar.java
+++ b/smart-flow-integration/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SmartFlowRegistrar.java
@@ -32,6 +32,7 @@ public class SmartFlowRegistrar implements ImportBeanDefinitionRegistrar {
registeredClasses.put(SpringObjectCreator.NAME, SpringObjectCreator.class);
registeredClasses.put(SpringBeanContextAdapter.NAME, SpringBeanContextAdapter.class);
registeredClasses.put(XmlParseReloader.class.getName(), XmlParseReloader.class);
+ registeredClasses.put(SpringAttributeValueResolver.class.getName(), SpringAttributeValueResolver.class);
}
@Override
diff --git a/smart-flow-integration/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SpringAttributeValueResolver.java b/smart-flow-integration/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SpringAttributeValueResolver.java
new file mode 100644
index 0000000000000000000000000000000000000000..473cd466bf33e9d1b9eecc7114601a2ec646e344
--- /dev/null
+++ b/smart-flow-integration/smart-flow-spring-extension/src/main/java/org/smartboot/flow/spring/extension/SpringAttributeValueResolver.java
@@ -0,0 +1,25 @@
+package org.smartboot.flow.spring.extension;
+
+import org.smartboot.flow.core.attribute.AttributeValueResolver;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+
+/**
+ * @author qinluo
+ * @date 2023-10-27 15:35:59
+ * @since 1.1.4
+ */
+public class SpringAttributeValueResolver extends AttributeValueResolver {
+
+ @Autowired
+ private Environment environment;
+
+ @Override
+ protected String earlyResolve(String value) {
+ try {
+ return environment.resolvePlaceholders(value);
+ } catch (Exception e) {
+ return value;
+ }
+ }
+}
diff --git a/smart-flow-integration/smart-flow-springboot-starter/pom.xml b/smart-flow-integration/smart-flow-springboot-starter/pom.xml
index 767f59a7d8a96d65ef996b0aadbfa7c26b41aba1..4e679ff3ea0e25148e5143563d0d13d65c179e3a 100644
--- a/smart-flow-integration/smart-flow-springboot-starter/pom.xml
+++ b/smart-flow-integration/smart-flow-springboot-starter/pom.xml
@@ -5,7 +5,7 @@
smart-flow-integration
org.smartboot.flow
- 1.1.3
+ 1.1.4
4.0.0
diff --git a/smart-flow-manager/pom.xml b/smart-flow-manager/pom.xml
index 1247b5d0a48bc692733cfb1ea781ccc9e02e91ad..d38f734f2c49413c76cdb3e798b090b1ab22eb2d 100644
--- a/smart-flow-manager/pom.xml
+++ b/smart-flow-manager/pom.xml
@@ -5,7 +5,7 @@
smart-flow-parent
org.smartboot.flow
- 1.1.3
+ 1.1.4
4.0.0
diff --git a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/FlatManager.java b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/FlatManager.java
index fd9ba0fc5d227c4a4346c19b376949b309fa6778..4c055d00e572a4e7e65e86cbe864d6cd1cc96fda 100644
--- a/smart-flow-manager/src/main/java/org/smartboot/flow/manager/FlatManager.java
+++ b/smart-flow-manager/src/main/java/org/smartboot/flow/manager/FlatManager.java
@@ -42,6 +42,7 @@ public class FlatManager {
engine.setReportContent(true);
XmlEngineVisitor visitor = new XmlEngineVisitor();
+ visitor.compressContent();
visitor.visit(source);
String content = visitor.getContent();
engine.setContent(content);
diff --git a/smart-flow-plugin/pom.xml b/smart-flow-plugin/pom.xml
index b76abb4969efe75476f5cbf898002d3b0d8ae035..e7cc2542c54f4dd809be0892cb657b25ddf5a8b8 100644
--- a/smart-flow-plugin/pom.xml
+++ b/smart-flow-plugin/pom.xml
@@ -6,7 +6,7 @@
org.smartboot.flow
smart-flow-parent
- 1.1.3
+ 1.1.4
smart-flow-plugin
diff --git a/smart-flow-plugin/smart-flow-bootstrap/pom.xml b/smart-flow-plugin/smart-flow-bootstrap/pom.xml
index 9ffc1b6509a7b00e4709fe45588f231d747c9759..2cd06faa390ce26db00cef1921fc76b588088f0c 100644
--- a/smart-flow-plugin/smart-flow-bootstrap/pom.xml
+++ b/smart-flow-plugin/smart-flow-bootstrap/pom.xml
@@ -6,7 +6,7 @@
org.smartboot.flow
smart-flow-plugin
- 1.1.3
+ 1.1.4
smart-flow-bootstrap
diff --git a/smart-flow-plugin/smart-flow-enhance-plugin/pom.xml b/smart-flow-plugin/smart-flow-enhance-plugin/pom.xml
index 22217006949c6ca8b149a287f82858f448cf169b..8bb46b106c826c76e809623ee5248d27579522ce 100644
--- a/smart-flow-plugin/smart-flow-enhance-plugin/pom.xml
+++ b/smart-flow-plugin/smart-flow-enhance-plugin/pom.xml
@@ -6,7 +6,7 @@
org.smartboot.flow
smart-flow-plugin
- 1.1.3
+ 1.1.4
smart-flow-enhance-plugin
diff --git a/smart-flow-script/pom.xml b/smart-flow-script/pom.xml
index af5a19dcaccd98d8494bd650a495969cc676c18d..724eb075972307789d7e86e1d4e72d1235a3c0bc 100644
--- a/smart-flow-script/pom.xml
+++ b/smart-flow-script/pom.xml
@@ -5,7 +5,7 @@
smart-flow-parent
org.smartboot.flow
- 1.1.3
+ 1.1.4
4.0.0
pom
diff --git a/smart-flow-script/smart-flow-script-groovy/pom.xml b/smart-flow-script/smart-flow-script-groovy/pom.xml
index 8febee5d7a28367db7ec31a330e582060594e780..428aef5125c4127880c38a75c7e2a66aa99a114a 100644
--- a/smart-flow-script/smart-flow-script-groovy/pom.xml
+++ b/smart-flow-script/smart-flow-script-groovy/pom.xml
@@ -5,7 +5,7 @@
smart-flow-script
org.smartboot.flow
- 1.1.3
+ 1.1.4
4.0.0
diff --git a/smart-flow-script/smart-flow-script-ognl/pom.xml b/smart-flow-script/smart-flow-script-ognl/pom.xml
index efd7c167d1842163aaea5db2e21fc89f3ff30215..3e0cb220fe65535788c056a70da796be768d967e 100644
--- a/smart-flow-script/smart-flow-script-ognl/pom.xml
+++ b/smart-flow-script/smart-flow-script-ognl/pom.xml
@@ -5,7 +5,7 @@
smart-flow-script
org.smartboot.flow
- 1.1.3
+ 1.1.4
4.0.0
diff --git a/smart-flow-script/smart-flow-script-qlexpress/pom.xml b/smart-flow-script/smart-flow-script-qlexpress/pom.xml
index 13519f07117359e2ad783e4c3d735ad02230575f..0c970b17657e0cfd02025a3e9ab4cc72b14eb0eb 100644
--- a/smart-flow-script/smart-flow-script-qlexpress/pom.xml
+++ b/smart-flow-script/smart-flow-script-qlexpress/pom.xml
@@ -5,7 +5,7 @@
smart-flow-script
org.smartboot.flow
- 1.1.3
+ 1.1.4
4.0.0