diff --git a/liteflow-benchmark/.gitignore b/liteflow-benchmark/.gitignore new file mode 100644 index 000000000..1f56396cc --- /dev/null +++ b/liteflow-benchmark/.gitignore @@ -0,0 +1,83 @@ +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so + + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip +*.war +*.del +*.pmd +.tern-project + + +# Logs and databases # +###################### +*.log +*.log.* +# OS generated files # +###################### +.DS_Store* +ehthumbs.db +Icon? +Thumbs.db + + +# Editor Files # +################ +*~ +*.swp + + +# Gradle Files # +################ +.gradle + + +# Build output directies +/target +*/target +/build +*/build + + +# IntelliJ specific files/directories +out +.idea +*.ipr +*.iws +*.iml +atlassian-ide-plugin.xml + + +# Eclipse specific files/directories +.classpath +.project +.settings +.metadata +.myeclipse + + +# NetBeans specific files/directories +.nbattrs + +*.mymetadata +/logs +*/logs + +.flattened-pom.xml \ No newline at end of file diff --git a/liteflow-benchmark/liteflow-benchmark-script-javax/pom.xml b/liteflow-benchmark/liteflow-benchmark-script-javax/pom.xml new file mode 100644 index 000000000..30405bb4c --- /dev/null +++ b/liteflow-benchmark/liteflow-benchmark-script-javax/pom.xml @@ -0,0 +1,23 @@ + + + + liteflow-benchmark + com.yomahub + ${revision} + ../pom.xml + + 4.0.0 + + liteflow-benchmark-script-javax + + + + com.yomahub + liteflow-script-javax + ${revision} + test + + + \ No newline at end of file diff --git a/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/ScriptJavaxBenchmark.java b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/ScriptJavaxBenchmark.java new file mode 100644 index 000000000..761d21597 --- /dev/null +++ b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/ScriptJavaxBenchmark.java @@ -0,0 +1,76 @@ +package com.yomahub.liteflow.benchmark; + +import cn.hutool.core.io.resource.ResourceUtil; +import com.yomahub.liteflow.builder.LiteFlowNodeBuilder; +import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder; +import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.flow.FlowBus; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; +import org.openjdk.jmh.runner.options.TimeValue; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.PropertySource; + +import java.util.concurrent.TimeUnit; + +@State(Scope.Benchmark) +@EnableAutoConfiguration +@PropertySource(value = "classpath:application.properties") +@ComponentScan("com.yomahub.liteflow.benchmark.cmp") +public class ScriptJavaxBenchmark { + + private ConfigurableApplicationContext applicationContext; + + private FlowExecutor flowExecutor; + + @Setup + public void setup() { + applicationContext = SpringApplication.run(ScriptJavaxBenchmark.class); + flowExecutor = applicationContext.getBean(FlowExecutor.class); + } + + @TearDown + public void tearDown() { + applicationContext.close(); + } + + /*@Benchmark + public void test1(){ + flowExecutor.execute2Resp("chain1"); + }*/ + + //每次编译一样的的script性能 + @Benchmark + public void test2(){ + String scriptContent = ResourceUtil.readUtf8Str("classpath:javaxScript.java"); + LiteFlowNodeBuilder.createScriptNode().setId("ds").setScript(scriptContent).build(); + + if(!FlowBus.containChain("chain2")){ + LiteFlowChainELBuilder.createChain().setChainId("chain2").setEL("THEN(ds)").build(); + } + flowExecutor.execute2Resp("chain2"); + } + + + public static void main(String[] args) throws RunnerException { + Options opt = new OptionsBuilder() + .include(ScriptJavaxBenchmark.class.getSimpleName()) + .mode(Mode.Throughput) + .warmupIterations(1)//预热次数 + .measurementIterations(3)//执行次数 + .measurementTime(new TimeValue(30, TimeUnit.SECONDS))//每次执行多少时间 + .threads(300)//多少个线程 + .forks(1)//多少个进程 + .timeUnit(TimeUnit.SECONDS) + .build(); + new Runner(opt).run(); + } +} diff --git a/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/ACmp.java b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/ACmp.java new file mode 100644 index 000000000..8c9d02813 --- /dev/null +++ b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/ACmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.benchmark.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("a") +public class ACmp extends NodeComponent { + + @Override + public void process() { + } + +} diff --git a/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/BCmp.java b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/BCmp.java new file mode 100644 index 000000000..1dc6a517f --- /dev/null +++ b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/BCmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.benchmark.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("b") +public class BCmp extends NodeComponent { + + @Override + public void process() { + } + +} diff --git a/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/CCmp.java b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/CCmp.java new file mode 100644 index 000000000..95ee9b80c --- /dev/null +++ b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/CCmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.benchmark.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; + +@LiteflowComponent("c") +public class CCmp extends NodeComponent { + + @Override + public void process() { + } + +} diff --git a/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/DCmp.java b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/DCmp.java new file mode 100644 index 000000000..d78b2ea33 --- /dev/null +++ b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/DCmp.java @@ -0,0 +1,23 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.benchmark.cmp; + +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; + +@LiteflowComponent("d") +public class DCmp extends NodeComponent { + + @Override + public void process() { + DefaultContext context = this.getFirstContextBean(); + context.setData("count", 198); + } + +} diff --git a/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/Person.java b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/Person.java new file mode 100644 index 000000000..be665958d --- /dev/null +++ b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/Person.java @@ -0,0 +1,28 @@ +package com.yomahub.liteflow.benchmark.cmp; + +public class Person { + private String name; + + private Integer salary; + + public Person(String name, Integer salary) { + this.name = name; + this.salary = salary; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getSalary() { + return salary; + } + + public void setSalary(Integer salary) { + this.salary = salary; + } +} diff --git a/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/TestDomain.java b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/TestDomain.java new file mode 100644 index 000000000..bbd999956 --- /dev/null +++ b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/cmp/TestDomain.java @@ -0,0 +1,25 @@ +package com.yomahub.liteflow.benchmark.cmp; + +import cn.hutool.core.collection.ListUtil; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class TestDomain { + + public String sayHello(String name){ + return "hello," + name; + } + + public static void main(String[] args) { + List personList = ListUtil.toList( + new Person("jack", 15000), + new Person("tom", 13500), + new Person("peter", 18600) + ); + + int totalSalary = personList.stream().mapToInt(Person::getSalary).sum(); + System.out.println(totalSalary); + } +} diff --git a/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/test/ScriptJavaxTest.java b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/test/ScriptJavaxTest.java new file mode 100644 index 000000000..2d8183146 --- /dev/null +++ b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/test/ScriptJavaxTest.java @@ -0,0 +1,72 @@ +package com.yomahub.liteflow.test; + +import cn.hutool.core.io.resource.ResourceUtil; +import com.yomahub.liteflow.builder.LiteFlowNodeBuilder; +import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder; +import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; +import org.openjdk.jmh.runner.options.TimeValue; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.PropertySource; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +import javax.annotation.Resource; +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicLong; + +@ExtendWith(SpringExtension.class) +@TestPropertySource(value = "classpath:application.properties") +@SpringBootTest(classes = ScriptJavaxTest.class) +@EnableAutoConfiguration +@ComponentScan({ "com.yomahub.liteflow.benchmark.cmp" }) +public class ScriptJavaxTest { + + @Resource + private FlowExecutor flowExecutor; + + // 测试普通脚本节点 + @Test + public void test1() { + ExecutorService executorService = new ThreadPoolExecutor(100, 100, 60, + TimeUnit.SECONDS, new ArrayBlockingQueue<>(500), new ThreadFactory() { + private final AtomicLong number = new AtomicLong(); + + @Override + public Thread newThread(Runnable r) { + Thread newThread = Executors.defaultThreadFactory().newThread(r); + newThread.setName("LF" + number.getAndIncrement()); + newThread.setDaemon(false); + return newThread; + } + }, new ThreadPoolExecutor.CallerRunsPolicy()); + + for (int i = 0; i < 10000; i++) { + executorService.submit(() -> { + String scriptContent = ResourceUtil.readUtf8Str("classpath:javaxScript.java"); + LiteFlowNodeBuilder.createScriptNode().setId("ds").setScript(scriptContent).build(); + + if(!FlowBus.containChain("chain2")){ + LiteFlowChainELBuilder.createChain().setChainId("chain2").setEL("THEN(ds)").build(); + } + LiteflowResponse response = flowExecutor.execute2Resp("chain2"); + DefaultContext context = response.getFirstContextBean(); + System.out.println(context.getData("salary").toString()); + }); + } + } +} diff --git a/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/resources/application.properties b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/resources/application.properties new file mode 100644 index 000000000..554d385f9 --- /dev/null +++ b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/resources/application.properties @@ -0,0 +1,3 @@ +liteflow.rule-source=flow.xml +liteflow.print-execution-log=true +liteflow.script-setting.javax-is-cache=false \ No newline at end of file diff --git a/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/resources/flow.xml b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/resources/flow.xml new file mode 100644 index 000000000..762bcf14c --- /dev/null +++ b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/resources/flow.xml @@ -0,0 +1,75 @@ + + + + + + personList = ListUtil.toList( + new Person("jack", 15000), + new Person("tom", 13500), + new Person("peter", 18600) + ); + + int totalSalary = personList.stream().mapToInt(Person::getSalary).sum(); + + ctx.setData("salary", 47100); + + return null; + } + } + ]]> + + + + + + + + + + + + + THEN(FOR(s2).DO(THEN(a, b, c, s1)), SWITCH(s3).TO(a,b)); + + \ No newline at end of file diff --git a/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/resources/javaxScript.java b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/resources/javaxScript.java new file mode 100644 index 000000000..ca90603c6 --- /dev/null +++ b/liteflow-benchmark/liteflow-benchmark-script-javax/src/test/resources/javaxScript.java @@ -0,0 +1,35 @@ +import cn.hutool.core.collection.ListUtil; +import com.yomahub.liteflow.benchmark.cmp.Person; +import com.yomahub.liteflow.benchmark.cmp.TestDomain; +import com.yomahub.liteflow.script.body.CommonScriptBody; +import com.yomahub.liteflow.slot.DefaultContext; +import com.yomahub.liteflow.spi.holder.ContextAwareHolder; +import com.yomahub.liteflow.script.ScriptExecuteWrap; + +import java.util.List; +import java.util.function.ToIntFunction; + +public class Demo implements CommonScriptBody { + public Void body(ScriptExecuteWrap wrap) { + int v1 = 2; + int v2 = 3; + DefaultContext ctx = wrap.getCmp().getFirstContextBean(); + ctx.setData("s1", v1 * v2); + + TestDomain domain = ContextAwareHolder.loadContextAware().getBean(TestDomain.class); + String str = domain.sayHello("jack"); + ctx.setData("hi", str); + + List personList = ListUtil.toList( + new Person("jack", 15000), + new Person("tom", 13500), + new Person("peter", 18600) + ); + + int totalSalary = personList.stream().mapToInt(Person::getSalary).sum(); + + ctx.setData("salary", 47100); + + return null; + } +} \ No newline at end of file diff --git a/liteflow-benchmark/pom.xml b/liteflow-benchmark/pom.xml new file mode 100644 index 000000000..7d92fb1b9 --- /dev/null +++ b/liteflow-benchmark/pom.xml @@ -0,0 +1,61 @@ + + + + liteflow + com.yomahub + ${revision} + ../pom.xml + + 4.0.0 + pom + + + liteflow-benchmark + + + 1.37 + + + + + + com.yomahub + liteflow-spring-boot-starter + ${revision} + + + org.springframework.boot + spring-boot-starter-test + + + + org.openjdk.jmh + jmh-core + ${jmh.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + + + + + liteflow-benchmark-script-javax + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.8.2 + + true + + + + + \ No newline at end of file diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java b/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java index 96c1fedc0..d269da250 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java @@ -8,6 +8,7 @@ */ package com.yomahub.liteflow.property; +import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.enums.ParseModeEnum; @@ -36,7 +37,7 @@ public class LiteflowConfig { // 流程资源扩展数据 private String ruleSourceExtData; - private Map ruleSourceExtDataMap = new HashMap<>(); + private Map ruleSourceExtDataMap; // slot的数量 private Integer slotSize; @@ -121,7 +122,7 @@ public class LiteflowConfig { private Boolean fastLoad; //脚本特殊设置选项 - private Map scriptSetting = new HashMap<>(); + private Map scriptSetting; public Boolean getEnableMonitorFile() { return enableMonitorFile; @@ -498,7 +499,11 @@ public class LiteflowConfig { } public Map getScriptSetting() { - return scriptSetting; + if (ObjectUtil.isNull(scriptSetting)) { + return MapUtil.empty(); + }else{ + return scriptSetting; + } } public void setScriptSetting(Map scriptSetting) { diff --git a/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/BooleanScriptBody.java b/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/BooleanScriptBody.java index c6be4e421..c52a1d80d 100644 --- a/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/BooleanScriptBody.java +++ b/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/BooleanScriptBody.java @@ -1,6 +1,10 @@ package com.yomahub.liteflow.script.body; - +/** + * Javax语言脚本布尔类型继承类 + * @author Bryan.Zhang + * @since 2.12.4 + */ public interface BooleanScriptBody extends ScriptBody { } diff --git a/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/CommonScriptBody.java b/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/CommonScriptBody.java index 90d4ef7d4..8164f6a6c 100644 --- a/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/CommonScriptBody.java +++ b/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/CommonScriptBody.java @@ -1,5 +1,10 @@ package com.yomahub.liteflow.script.body; +/** + * Javax语言脚本普通类型继承类 + * @author Bryan.Zhang + * @since 2.12.4 + */ public interface CommonScriptBody extends ScriptBody { } diff --git a/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/ForScriptBody.java b/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/ForScriptBody.java index 92a47274e..2d8f4fec0 100644 --- a/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/ForScriptBody.java +++ b/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/ForScriptBody.java @@ -1,6 +1,10 @@ package com.yomahub.liteflow.script.body; - +/** + * Javax语言脚本FOR类型继承类 + * @author Bryan.Zhang + * @since 2.12.4 + */ public interface ForScriptBody extends ScriptBody { } diff --git a/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/ScriptBody.java b/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/ScriptBody.java index 2d3414098..7b47fc8d4 100644 --- a/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/ScriptBody.java +++ b/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/ScriptBody.java @@ -2,6 +2,11 @@ package com.yomahub.liteflow.script.body; import com.yomahub.liteflow.script.ScriptExecuteWrap; +/** + * Javax语言脚本继承类的接口 + * @author Bryan.Zhang + * @since 2.12.4 + */ public interface ScriptBody { T body(ScriptExecuteWrap wrap); } diff --git a/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/SwitchScriptBody.java b/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/SwitchScriptBody.java index 854d42307..6b775b8a2 100644 --- a/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/SwitchScriptBody.java +++ b/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/body/SwitchScriptBody.java @@ -1,6 +1,10 @@ package com.yomahub.liteflow.script.body; - +/** + * Javax语言脚本Switch类型继承类 + * @author Bryan.Zhang + * @since 2.12.4 + */ public interface SwitchScriptBody extends ScriptBody { } diff --git a/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/javax/JavaxExecutor.java b/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/javax/JavaxExecutor.java index ff17c739e..f4b05af6f 100644 --- a/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/javax/JavaxExecutor.java +++ b/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/javax/JavaxExecutor.java @@ -17,6 +17,11 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +/** + * Javax语言执行器,基于liquor + * @author Bryan.Zhang + * @since 2.12.4 + */ public class JavaxExecutor extends ScriptExecutor { private final Map compiledScriptMap = new CopyOnWriteHashMap<>(); @@ -74,10 +79,14 @@ public class JavaxExecutor extends ScriptExecutor { @Override public Object compile(String script) throws Exception { - CodeSpec codeSpec = new CodeSpec(convertScript(script)) - .returnType(Object.class) - .parameters(new ParamSpec("_meta", ScriptExecuteWrap.class)).cached(isCache); - return Scripts.compile(codeSpec); + try{ + CodeSpec codeSpec = new CodeSpec(convertScript(script)) + .returnType(Object.class) + .parameters(new ParamSpec("_meta", ScriptExecuteWrap.class)).cached(isCache); + return Scripts.compile(codeSpec); + }catch (Exception e){ + return e; + } } private String convertScript(String script){ diff --git a/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/javax/vo/JavaxSettingMapKey.java b/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/javax/vo/JavaxSettingMapKey.java index 286c46500..3e1bd1912 100644 --- a/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/javax/vo/JavaxSettingMapKey.java +++ b/liteflow-script-plugin/liteflow-script-javax/src/main/java/com/yomahub/liteflow/script/javax/vo/JavaxSettingMapKey.java @@ -1,6 +1,11 @@ package com.yomahub.liteflow.script.javax.vo; +/** + * Javax语言特殊配置项的Key + * @author Bryan.Zhang + * @since 2.12.4 + */ public interface JavaxSettingMapKey { - String IS_CACHE = "isCache"; + String IS_CACHE = "javax-is-cache"; } diff --git a/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 7b004ba76..83b0b668e 100644 --- a/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -216,7 +216,7 @@ "defaultValue": "com.yomahub.liteflow.thread.LiteFlowDefaultParallelLoopExecutorBuilder" }, { - "name": "liteflow.scriptSetting", + "name": "liteflow.script-setting", "type": "java.util.Map", "description": "script special settings.", "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty" diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-javax-springboot/src/test/resources/common/application.properties b/liteflow-testcase-el/liteflow-testcase-el-script-javax-springboot/src/test/resources/common/application.properties index 4c9c216b6..32a15aec3 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-script-javax-springboot/src/test/resources/common/application.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-script-javax-springboot/src/test/resources/common/application.properties @@ -1 +1,2 @@ -liteflow.rule-source=common/flow.xml \ No newline at end of file +liteflow.rule-source=common/flow.xml +liteflow.script-setting.javax-is-cache=false \ No newline at end of file diff --git a/pom.xml b/pom.xml index 5c4b377a1..b7b108f64 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ 3.21.0 3.1.12 1.9.23 - 1.3.3 + 1.3.5-SNAPSHOT @@ -449,6 +449,7 @@ liteflow-testcase-el liteflow-el-builder liteflow-script-plugin/liteflow-script-javax + liteflow-benchmark