Chapter 2. Using Rule Flow for the First Time
Read this section to learn how to create and execute your first Ruleflow process.
2.1. Creating Your First Process Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Use the JBoss Business Developer Studio (JBDS) to create an executable project that contains the files necessary to start defining and executing processes.
Step through the wizard to generate a basic project structure, a class-path, a sample process and execution code. (To create a new JBoss Rules project, left-click on the button (with the JBoss Rules heading) in the IDE toolbar and select .
Note
The JBoss Rules action button only shows up in the JBoss Rules perspective. To open the JBoss Rules perspective (if you haven't done so already), click the button in the top right corner of your IDE window, select and pick the JBoss Rules perspective.
Alternatively, you could select , then followed by , and in the JBoss Rules directory, select JBoss Rules Project.
Give your project a name and click .
In the following dialogue box, you can select which elements you wish to add to your project by default. Since you are creating a new process, clear the first two check-boxes and select the last two. This will generate a sample process and a Java class to execute this process.
If you have not yet set up a JBoss Rules run-time, do so now. A JBoss Rules run-time is a collection of Java Archive files (JARs) that represent one specific release of the JBoss Rules project JARs.
To create a runtime, either point the IDE to the release of your choice, or create a new runtime on your file system from the JARs included in the JBoss Rules IDE plug-in. (Since you want to use the JBoss Rules version included in this plug-in, you will do the latter this time.)
Note
You will only have to do this once; the next time you create a JBoss Rules project, it will automatically use the default runtime (unless you specify otherwise).
Unless you have already set up a JBoss Rules run-time, click the button.
A dialogue box will appear, telling you that you have not yet defined a default JBoss Rules runtime and that you should configure the workspace settings first. Do this by clicking on the Configure Workspace Settings... link.
The dialogue box that will appear shows you the workspace settings for the JBoss Rules run-times. (The first time you do this, the list of installed JBoss Rules run-times will be empty.)
To create a new run-time on your file system, click the button.
Use the dialogue box that appears to give the new run-time a name (such as "JBoss Rules 5.2 runtime"), and put a path to your JBoss Rules run-time on your file system.
Click the button and select the directory in which you want this run-time to be stored.
Click the button. You will see the path you selected showing up in the dialogue box.
Click the button. You will see the newly created run-time shown in your list of all the JBoss Rules run-times.
Select this runtime and make it the new default by clicking on the check box next to its name and clicking .
After successfully setting up your run-time, you can now dismiss the Project Creation Wizard by clicking on the button.
The end result will contain the following:
ruleflow.rf: this is the process definition file. In this case, you have a very simple process containing a Start node (the entry point), an Action node (that prints out "Hello World") and an End node (the end of the process).RuleFlowTest.java: this is the Java class that executes the process.- the libraries you require. These are automatically added to the project class-path in the form of a single JBoss Rules library.
Double-click on the
ruleflow.rf file. The process will open in the Rule Flow Editor. (The Rule Flow Editor contains a graphical representation of your process definition. It consists of nodes that are connected to each other.) The Editor shows the overall control flow, while the details of each of the elements can be viewed (and edited) in the Properties View at the bottom.
On the left-hand side of the Editor window, you will see a palette. Use this to drag-and-drop new nodes. You will also find an outline view on the right-hand side.
Note
While most readers will find it easier to use the Editor, you can also modify the underlying XML directly if you wish. The XML for your sample process is shown below (note that the graphical information is omitted here for the sake of simplicity).
The process element contains parameters like the name and id. of the process, and consists of three main subsections: a header (where information like variables, globals and imports can be defined), the nodes and the connections.