🪶Pass initialized context
You may have noticed that when the executor executes the chain, it needs to pass in two parameters: the process input parameter and the context class definition (one or more).
There are specific instructions about the process entry in the Process entry chapter.
For data contexts, context initialization is handled by the framework. That is, when you execute the first component, there is no user data in the context object. And your process input parameters are obtained with this.getRequestData()
, this part is not included in the context.
If you need to put the process parameters into the context, then this action needs to be done by yourself.
Some people may find this step a little cumbersome.
Starting from version 2.8.4, LiteFlow allows users to pass in one or more initialized beans as context instead of passing in class objects.
After getting the FlowExecutor
, you can pass in the initialized bean as the context as follows (of course, multiple contexts are also supported, only a single context is demonstrated here):
OrderContext orderContext = new OrderContext();
orderContext.setOrderNo("SO11223344");
LiteflowResponse response = flowExecutor.execute2Resp("chain1", null, orderContext);
If you call it like this, it means that some data has been initialized in your context. In a sense, this is already equivalent to process input parameters
, so when using this, you can completely omit the process input parameters.
警告
LiteFlow does not support the mixing of context beans and classes. You either pass both beans or both classes.