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
      • Methods that can be overridden
        • isAccess
        • isContinueOnError
        • isEnd
        • beforeProcess and afterProcess
        • onSuccess and onError
      • Methods that the This keyword can call
        • Get context
        • getNodeId
        • getName
        • getChainName
        • getRequestData
        • setIsEnd
        • getTag
        • invoke and invoke2Response
      • @LiteflowComponent
    • ✂️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
  • 🎨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文档
  • 🔗General components
铂赛东
2022-06-29
Contents

📎Common component

Common component nodes need to inherit the NodeComponent class, which can be used in the THEN and WHEN keywords.

Need to implement the process method:

@LiteflowComponent("a")
public class ACmp extends NodeComponent {

	@Override
	public void process() {
		System.out.println("ACmp executed!");
	}
}

tip

@LiteflowComponent inherits from @Component, if you are in the spring system environment, you can inject any spring beans into the component for use.

The parameter a of @LiteflowComponent is the component ID you need to use when writing EL rules.

# Methods that can be overridden

For components, the following methods in the superclass can be overridden.

# isAccess

It is recommended to implement the isAccess method, indicating whether to enter the node, which can be used for pre-judgment of business parameters.

# isContinueOnError

Indicates whether the error continues to execute the next component, the default value is false.

# isEnd

If it returns true after overwriting, it means that the entire process will be terminated immediately after the component is executed. For this method, since it is a process that the user voluntarily ends, it is a normal end, so the final isSuccess is true.

tip

It should be noted that if this.setIsEnd(true) is called when isContinueOnError is true, it will still terminate. The isSuccess in the response is still true.

# beforeProcess and afterProcess

The pre- and post-processors of the process, where the pre-processor is executed after isAccess.

Used to perform some pre- and post-processing, but generally this is not needed. If it is to do the component front and rear in a unified way, it is recommended to use the aspect to complete it. For the aspect, please refer to Component aspect.

# onSuccess and onError

The success or failure event callback of the process, please refer to Component Event Callback for details.

# Methods that the This keyword can call

# Get context

In the component node, you can get the context defined by yourself through the method this.getContextBean(clazz) at any time, so that you can get any data.

# getNodeId

Get the component ID.

# getName

Get component alias.

# getChainName

Get the currently executing Chain name.

# getRequestData

Get the initial parameters of the Chain.

# setIsEnd

Indicates whether to end the entire process immediately, the usage is this.setIsEnd(true). For this method, since it is a process that the user voluntarily ends, it is a normal end, so the final isSuccess is true.

notice

It should be noted that if this.setIsEnd(true) is called when isContinueOnError is true, it will still terminate. The isSuccess in the response is still true.

# getTag

Get the label information of this component. For the definition and use of labels, please refer to Component Labels.

# invoke and invoke2Response

Call the implicit process. For the description and usage of the implicit process, please refer to Implicit Chain.

# @LiteflowComponent

Since v2.6.0, the @LiteflowComponent tag has been added, which is inherited from Spring's @Component tag, so in terms of function, it is no different from the @Component tag, but @LiteflowComponent A new name attribute has been added to alias the component, which will be reflected when printing the call chain. For details, please refer to the Printing Details chapter. Starting with the new version, it is recommended that you use @LiteflowComponent, of course, @Component can also continue to be used.

Help us improve this document (opens new window)
last update: 2022/10/13, 00:02:27
📙Custom source
✂️Switch component

← 📙Custom source ✂️Switch component→

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