Imperative
Imperative construction of an execution graph
Last updated
Imperative construction of an execution graph
Last updated
The goal is to construct a graph described imperatively in code.
Fluxtion provides a builder class, SEPConfig that can be extended by the user to implement imperative description logic. The Fluxtion event stream compiler consults the SEPConfig sub-class to build an execution graph. Specifying the SEPConfig file to use by Fluxtion is covered in the tool section.
Analysis is performed with the following rules:
Fluxtion instantiates the builder class at build time.
Application classes are loaded at compile time for analysis.
The buildConfig()
method is invoked before analysis. A user can add nodes to the graph in their overriden buildConfig()
implementation.
Node instances are instantiated in buildConfig() and added to SEPConfig data structures imperatively by the user.
With imperative construction only nodes added to the SEPConfig data structures will be included in the final graph.
The SEPConfig data structures are analysed and the graph built after buildConfig() has exited.
The data structures from SEPConfig that are read by Fluxtion compiler are:
SEPConfig provides other members that can control the code generation process, but the data structures above are the ones used to include the instances within the final graph. Further detailed discussion of the SEPConfig is in the tools section.
To generate the final code Fluxtion employs the following rules for reference setting in the SEP.
References can public, setter bean pattern or constructor.
private final members will be considered as constructor parameters.
A constructor must exist that matches exactly the number and type of private final members.
If there are multiple args of the same type, then the parameter name will be used to match arg to member. Use -parameters switch in javac to generate parameter names at compile time.
The Fluxtion compiler processes the SEPConfig and the user classpath to generate the SEP. A user invokes the executable jar fluxtion.jar with a set of parameters to run a generation cycle. The compiler tool is covered in detail here or used via the maven plugin here. The maven plugin is easier for the developer to integrate into the development process.
The fluxtion maven plugin prints to console the command line needed to run the fluxtion.jar directly.
The command to run the compiler takes the following form:
The following example demonstrates adding three nodes for inclusion in the generated SEP. A variety of approaches are used for setting references between nodes, including:
constructor referring to final fields - line 6
bean pattern getter/setter - line 8
public variable - line 9
Each node must be individually added to the graph using addNode or addPublicNode. Using addPublicNode creates a public variable of type SubNode declared with the name "subNode" in the final SEP. The add methods return a reference to the node added.
For this example the command line to invoke Fluxtion ESC will be similar to the one shown below.
A number of reference setting strategies are used in the generated SEP including: constructor based, bean pattern and public variable. The constructor is used in node declarations, while the other methods are used in the constructor of the SEP.
Structure
Helper method
Description
nodeList
<T> T addNode(T node)
List of node instances in graph. Private scope
publicNodes
<T> T addPublicNode(T node, String name)
Map nodes with variable name. Public final scope
auditorMap
<T> T addAuditor(T listener, String name)
Auditor to include with variable name. Public scope