FlowX is a framework that aims to offer simple yet complete basis to write and to define flows in XML files. It has been inspired by the spring web flow-framework and spring users will recognize some parts of it.
A flow is defined in the XML format (show examples below). A flow has an id and a start attribute. The start is the staring point of the flow, it references a flow part in the flow to start with.
A flow definition consists of flow steps defined as flow parts.
Each flow part, referenced by a unique id, has associated to it an execution action class and contains transitions. Transitions allows to define the next flow parts to jump to, depending on the action returned result.
Here is a XML flow definition of the "Hello World!" example presented further:
<?xml version="1.0" encoding="UTF-8"?>
<flow id="hello-flow" start="action1">
<flowpart id="action1" action="com.ichir.projects.flowx.Action1">
<transition id="next" target="action2" />
</flowpart>
<flowpart id="action2" action="com.ichir.projects.flowx.Action2">
<transition id="yes" target="action1" />
<transition id="no" target="action3" />
</flowpart>
<flowpart id="action3" action="com.ichir.projects.flowx.Action3" />
</flow>
A flow part action class is the execution class. Actions are implementations of the com.ichir.projects.flow.IAction. They must override the execute(Map<string, object="">):String</string,> method.
A flow part transition has an id and a target. The transition target makes reference to another flow part in the current flow. The transition id corresponds to a result returned by the flow part action class.
The XML flow definition is loaded using the com.ichir.projects.flowx.xml.XmlFlowLoader helper class through the load(InputStream):IFlowDefinition static method.
Once the flow definition loaded, a IFlowDefinition instance, the flow is started using the com.ichir.projects.flowx.FlowBootstrap bootstrap class through the start(IFlowDefinition, Map<string, object="">):void</string,> method, the flow will start by the flow part referenced as a start part in the flow definition.
The second input parameter Map<string, object=""></string,> allows you register initial properties into the flow that are passed to execution action classes. These properties have a flow scope.
In this "Hello World" example, the program, on flow startup, will ask the user for its name, displays "Hello name!" and then asks the user whether to repeat the sequence or to quit.