In this chapter, we will write "Hello World" program using jBPM by following the steps given below
Go to File → New → Drools Project −
Click Next and give appropriate name for the first project : "HelloWorld" in our case.
Click Next and select the bottom two checkboxes, viz
Click Next and click on Configure Workspace Settings (marked red in below screenshot)
Click the Add button
When you click on Add button, below screen will appear. Click "Create a new Drools5 Runtime"
Give the path till the binaries folder where you have downloaded the droolsjbpm-tools-distribution-5.3.0.Final.zip
Then, select the Installed Drools Runtimes and click OK.
Below screenshot will appear. Click on Finish button.
Now, open the Package Explorer view in Eclipse where you can see below screen
ProcessTest.java class is the class for loading the ruleflow(rf) file and ruleflow.rf is the basic rule flow created for the HelloWorld project.
Double click on the ruleflow.rf file. You will see below ruleflow
GREEN circle represents the start of the workflow and RED circle represents the end of workflow.
Panel showed on the left-hand side will have different components listed which are used in the workflow. Apart from START and END, there are a lot of other components which can be used in the workflow. We will discuss about those components in the next section.
Hello in between START and END event is a script task and the name of the script task is Hello. To see what code is written in the script task "Hello", go to Windows → Show View → Other → Properties.
Note − While working on jBPM, keep the Properties view always open as all the configurations will be visible in the properties view only.
Click the OK button. Now, select Hello and you can see the properties of "Hello" event
To view the entire code written inside the "Hello" event, select the Action property.
Circle marked in red is the edit of the action property. Once you click on Edit
You can edit this and write the code which you wish to execute inside the "Hello" script task. Let us edit it
Click OK. Now open ProcessTest.java class and run it as a Java Application. Below is the output
Terms used in the ProcessTest.java class will be the same for Drools but the point to remember in ProcessTest.java class is
When you write the code for starting the process, string passed to startProcess method is the id property when we open the workflow.
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.