JBPM6 provides the flexibility to extend the default process constructs with domain-specific extensions.

The domain-specific work items (also called service nodes) specify the work that should be executed in the context of a process in a declarative approach.

 

Here is a simple example that shows the usage of  a custom workitem that has a few parameters.
This custom extension feature provides the ability to create a service task, a generic way to interact with external services (e.g., REST, JMS, Web service etc).

Start with the setup as shown in https://community.jboss.org/people/bpmn2user/blog/2013/12/17/jbpm6--eclipse-plugin-installation.


This example has a bpmn file that has the custom WorkItem(sample.bpmn), two WorkItem configurations files (CustomWorkItem.wid and drools.rulebase.conf), WorkItem implementation class (HelloProcessExtension.java) and test class (ProcessTest.java).

 

explore.png

 


Here is the configuration file CustomWorkItem.wid that provides information about the display name, parameter types etc and it should be placed in the project classpath (in PROJECT/src/main/resources/META-INF/CustomWorkItem.wid). Any custom icons for the workitems are places in  PROJECT/src/main/resources/icons.

 

custonworkitem_wid.png

The definition of the workitem (CustomWorkItem.wid) needs to be registered in a project. It can be done by including the definition using the drools.WorkDefinitions property in a file drools.rulebase.conf in META-INF dircectory.

drools_rulebase_conf.png

After creating a definition and registering the workitem, it will show up in designer. The Eclipse might need to be restarted after creating the configuration files(i.e, CustomWorkItem.wid and drools.rulebase.conf files in META-INF directory of the project)

The new workitem 'HelloProcessExtension' can be seen in 'Service Tasks' as shown below.

bpmn2processdiag.png

 

 

'HelloProcesExtension' node can be created inside the process using drag and drop.

 

 

processvariables.png

 

processparammapping.png

 

mappingdetail.png

 

A WorkItemHandler implementation class needs to be created for the 'HelloProcessExtension' node.

 

 

HelloProcessExtensionWorkitemhandler.png

 

The WorkItemHandler should be registered at the WorkItemManager, using API as shown below (in ProcessTest.java)

mainprg.png

After running the test class 'ProcessTest.java', following results can be seen.

results.png