LiteFlow LiteFlow
💒Home
📚Documents
💖Donation
🚀Plugin
  • About LiteFlow
  • Update Record
Community
Users
Gitee (opens new window)
Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)
💒Home
📚Documents
💖Donation
🚀Plugin
  • About LiteFlow
  • Update Record
Community
Users
Gitee (opens new window)
Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)
  • 🍤Introduction
  • 🍓Features
  • 🍟Quick Start(Hello world)

    • 🍄Notice
    • 🌿Springboot environment

      • 🧬Dependency
      • ⚙️Config
      • 🛫Execute
    • 🌱Spring environment

      • 🧬Dependency
      • ⚙️Config
      • 🛫Execute
    • 🌵Other environment

      • 🍄Notice
      • 🧬Dependency
      • ⚙️Config
      • 🛫Execute
  • 🍢Configuration item

    • 🍄Notice
    • 🌿Springboot environment
    • 🌱Spring environment
    • 🌵Other environment
  • 🗂Rules file

    • 📔Rules file format
    • 📕Local rule file
    • 📗Zookeeper source
    • 📘SQL database source
    • 📋Nacos source
    • 🗄Etcd source
    • 📙Custom source
  • 🔗General components

    • 📎Common component
    • ✂️Switch component
    • 📌If component
    • 🧬For component
    • ⛓While component
    • 🧿Break component
  • 🧩How to write EL rules

    • 🍄Notice
    • 🌴Serial mode
    • 🎋Parallel mode
    • 🌾Switch mode
    • 🌵If mode
    • 🌳Loop mode
    • 🍁Use sub chain
    • 🍂Use sub variables
    • 💐Complex example
    • 🌻About semicolons
    • 🌰About comments
    • 🐚Component Name Package
  • 🌮Data context

    • 🍄Notice
    • 🌯Definition and use
    • 🪶Pass initialized context
  • 🛩Flow executor

    • 🍄Notice
    • 🎡Executor method
    • 🎢Chain input parameter
    • 🎈LiteflowResponse object
  • 🍋Script component

    • 🍫Choose a script language
    • 🍕Define script component
    • 🌯Define file script
    • 🍣Interact with java
    • 🍘Dynamic refresh script
  • 🍇Declarative component

    • 🥭What is a declarative component
    • 🧅Class level declaration
    • 🥥Method level declaration
  • 🎲Dynamic rules

    • 🍄Notice
    • 🎯How to build
      • When to build
      • Build Node
      • Build Chain
      • Remove Chain
  • 🎨Advanced features

    • 🍒Pre & Finally components
    • 🥠Substitute component
    • 🍉Component Parameters
    • 🍑Component alias
    • 🍍Component tag
    • 🥝Component event
    • 🥑Implicit chain
    • 🍕Private delivery
    • 🍣Component retry
    • 🍖Smooth hot refresh
    • 🍪Component aspect
    • 🍡Step information
    • 🧊Exceptions
    • 🧇Printing details
    • 🧁Custom request id
    • 🌭Multiple type rules
    • 🥗Asynchronous thread pool
    • 🍿Custom component executor
    • 🍥Simple monitor
    • 🧉DTD in Xml
  • ⛱Test cases and demo

    • 🪁Test cases
    • 🪀Demo
  • 🪂Performance
  • v2.9.X文档
  • 🎲Dynamic rules
铂赛东
2022-07-02
Contents

🎯How to build

It should be noted that the dynamic rule mode and the rule file mode do not actually conflict. They can be used alone or in combination.

# When to build

It is recommended to build at project startup, rules only needs to be build once. Do not build it every time you execute it! ! !

# Build Node

tip

You can build a common Node like the following, of course in the spring/springboot environment, you don't need to build a Node in most cases, because as long as your component is marked with @Component/@LiteflowComponent, the component will be scanned to and register automatically.

I just tell you that you can build it through code in this way. If your component is a dynamic proxy class instead of a statically existing java class, or a script node, such a building makes sense.

For the concept of script nodes, you can view Script Components

//Build a common component
LiteFlowNodeBuilder.createCommonNode().setId("a")
                .setName("cmpA")
                .setClazz("com.yomahub.liteflow.test.builder.cmp.ACmp")
                .build();

//Build a switch component
LiteFlowNodeBuilder.createSwitchNode().setId("a")
                .setName("cmpA")
                .setClazz("com.yomahub.liteflow.test.builder.cmp.ACmp")
                .build();

//Build a script common component
LiteFlowNodeBuilder.createScriptNode().setId("a")
                .setName("cmpA")
                .setScript("your script text")
                .build();

//Build a script switch component
LiteFlowNodeBuilder.createScriptSwitchNode().setId("a")
                .setName("cmpA")
                .setScript("your script text")
                .build();

//Build a script component that loads from file
LiteFlowNodeBuilder.createScriptNode().setId("a")
                .setName("cmpA")
                .setFile("xml-script-file/s1.groovy")
                .build();

tip

Remind again, if you are in a spring/springboot environment, you don't need to define components. Suggest scan into spring context

The node class here does not require you to declare @LiteflowComponent or @Component. If the project is a spring system, the LiteFlow framework will automatically inject the node class into the spring context.

So you can still use any spring annotations like @Autowired and @Resource etc in this class.

# Build Chain

You can build a chain like the following, since it does not conflict with the rules defined. You can also use it in combination with rules files. When building, add it if it doesn't exist, and modify it if it exists.

LiteFlowChainELBuilder.createChain().setChainName("chain2").setEL(
  "THEN(a, b, WHEN(c, d))"
).build();

It is worth mentioning that since using the building mode is one by one, if you use a sub-process, if chain1 depends on chain2, then chain2 must be constructed first. Otherwise, an error will be reported.

However, after the study of the above chapters, in fact, an EL expression can represent a complex process, and even if it cannot, you can use sub-variables to optimize the process.

# Remove Chain

LiteFlow allows you to manually run the following code to destroy a chain:

FlowBus.removeChain("yourChainName")
Help us improve this document (opens new window)
last update: 2022/10/13, 00:02:27
🍄Notice
🍒Pre & Finally components

← 🍄Notice 🍒Pre & Finally components→

Theme by Vdoing | Copyright © 2020-2022 铂赛东 | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式