jBPM5 Hello World! - jBPM

How to write Hello World program using jBPM5?

In this chapter, we will write "Hello World" program using jBPM by following the steps given below

Go to File → New → Drools Project −

new_project

Click Next and give appropriate name for the first project : "HelloWorld" in our case.

drools_project

Click Next and select the bottom two checkboxes, viz

  • Add a sample HelloWorld process file to this project
  • Add a sample class to load and execute HelloWorld process

new_drools_project

Click Next and click on Configure Workspace Settings (marked red in below screenshot)

drools_runtime

Click the Add button

add

When you click on Add button, below screen will appear. Click "Create a new Drools5 Runtime"

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.

installed_drools_runtimes

Below screenshot will appear. Click on Finish button.

finish_button

Now, open the Package Explorer view in Eclipse where you can see below screen

package_explorer

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

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.

show_view

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

properties_of_hello

To view the entire code written inside the "Hello" event, select the Action property.

action_properties

Circle marked in red is the edit of the action property. Once you click on Edit

action_editor

You can edit this and write the code which you wish to execute inside the "Hello" script task. Let us edit it

action_editor1

Click OK. Now open ProcessTest.java class and run it as a Java Application. Below is the output

java_application

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.

start_process

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

jBPM Topics