|
Flow4j.RunFlows | News |
|
Running A FlowPrerequisitesyou need the libraryflow4j-runtime.-xxx.jar in order to access the FlowManager and flows.
GeneralA flow is an ordinary java class as many others. TheFlow class implements the IFlow interface that has one method:start(String startFlowletName, Map dictionary)Theoretically you can create an instance of a flow and call its start-method. A better way is to use the FlowManager, that caches singleton instances of already used flows. Instantiating a class is not cheep, so accessing flows through the FlowManager increates the apllications performance. A Flow can have more than one StartFlowlet, which act as entry points of the flow. The second parameter is a Map that holds read/write information while the flow is executed. For example the dictionary can be populated with data before the flow is started, then some floelets change the dictionary's data and when the flow execution is finished, the calling application can retrieve the expected data from the map. A flow is a collection of flowlets which are connected individually together. The comparison to process steps is not fully correct, because a StartFlowlet or a DecisionFlowlet fullfills no task. The TaskFlowlet on the other hand executes code, eg. java bytecode, and can be called a process step Saved Flow FormatIf you save a flow in the FlowDesigner a file with prefix ".flow" will be created in the specified directory. Every flow file is a jar-file. For example the flow "PutInBasket" contains the following:
Java Application EnvironmentIn a runtime environment all flows are started by the flow manager. The flow manager is a singleton class that implements some staticstart(...) methods to run a flow. While flow execution a Map is passed around between the linked flowlets thats content can be populated/updated by the various flowlets. The following code snippet shows the possible ways to run a flow in a java application.
import flow4j.flow.FlowMgr;
import flow4j.flow.FlowDictionary;
static public main(String[] args) {
FlowMgr.start("MyFlow-Start");
FlowMgr.start("MyFlow", "Start");
FlowDictionary dictionary = new FlowDictionary();
dictionary.put("name", "Alex");
FlowMgr.start("MyFlow-Start", dictionary);
FlowMgr.start("MyFlow", "Start", dictionary);
}
After the flow executed, the dictionary may contain key-value-pairs that was placed there by some flowlets. This information can be used by the calling application for further processes. Another way to use the dictionary is to provide the contents for a JSP page.
Web Application EnvironmentTo run flows in an application server environment you need a J2EE capable app server like tomcat, jetty or resin.Do the following steps to trigger a flow by your browser:
<servlet>
<servlet-name>FlowServlet</servlet-name>
<display-name>Flow4J Servlet</display-name>
<servlet-class>flow4j.servlet.FlowServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FlowServlet</servlet-name>
<url-pattern>*/FlowServlet/*</url-pattern>
</servlet-mapping>
{protocol}://{ip or domain}:{port}/{webapp-context}/{servlet-url-pattern}/{flowname}-{startname}?{key-value-pair}&...
Here you see some examples:
|
v0.5.1 released minor changes v0.5 released FlowServlet implemented Flowlet interface changed new Flowlets: Call, Jump, Join v0.4.5 released Bugfix release v0.4.4 released EndFlowlet introduced. DecisionFlowlet implemented. TemplateFlowlet implemented. v0.4.3 released Using Kopi compiler instead of InstantJ. Checking some Flow errors. v0.4.2 released TaskFlowlet properties implemented Ant buildfile redesigned. Avaliable for windows too. many samples! v0.4.1 released Bugfixes and designer improvements. v0.4 released Designer is written in Nice. Compiles the flow while saving in jar file. Missing Flowlets will follow soon. Designer relaunch The Designer will be completely rewritten without JHotDraw. The saved flow format will change!!! |