Implementing a Flow4J Task in a Scripting LanguageBean Scripting FrameworkFlow4J uses the Bean Scripting Framework (BSF) to execute scripts written in scripting languages like Python, Groovy, JudoScript and others. Here is a short excerpt from the Apache Jakarta site that explains BSF Bean Scripting Framework (BSF) is a set of Java classes which provides scripting language support within Java applications, and access to Java objects and methods from scripting languages. The Jakarta BSF implementation supports a lot of scripting languages out of the box. A registered language has the following components:
Scripting in Flow4JThe BSF implementation (bsf.jar) is by default part of the Flow4J-Eclipse plug-in. Thus all scripting langauges available in the BSF implementation are also available in Flow4J. To see a list of these languages open the Eclipse preferences through menu Window- > Preferences- > Flow4J- > BSF. The following image shows the Flow4J BSF panel where you can add a new scripting enine or change/extend the language extensions.
Note:
Scripted Task FlowletsAs already described in the Flow4J user manual, a task flowlet is an atomic functional part of the flow. Or in other terms, it is a reusable process step in a process. In the uer manual I described tasks all written in Java. With the help of BSF a task can be written in any scripting language that is BSF compliant and registered at the BSF framework. So it is possible to model a flow that has task flowlets implemented in different scripting languages!. The following image shows a flow that first executes a Java task, then a Python task and after this a Groovy task. Accessing the Flow Dictionary from Scripts
Accessing and manipulating the flow dictionary from inside a script is possible.
The flow dictionary extends the Java
Declared beans are beans that are named and which the engine must make available to the scripts it runs in the most first class way possible.
The name of the declared flow dictionary is:
dictionary
Changing or deleting the dictionary's contents is of coururse possible too. Adding Script Flowlets to a FlowMay be you have recognized that there is no script task tool in the Flow4J designer's tool palette. The reason for this is that script tasks won't be used so often as ordinary task flowlets written in Java. Currently there is only one way to add a scripted task flowlet to the designer, through drag and drop . All script files which extension is defined in the Flow4J BSF properties can be dropped on the designer.
Note:
|