JBPM5 provides the flexibility to extend the default process constructs with domain-specific extensions.
Here is a simple example that shows the usage of a custom workitem.
This custom extension feature provides the ability to create a service task, a generic way to interact with external services (e.g., JMS, Web service etc).
How to install and run this example?
Start with the setup as shown in http://community.jboss.org/people/bpmn2user/blog/2011/02/27/helloprocess-example-using-jbpm5-eclipse-plug-in.
This example has a bpmn file that has the custom WorkItem(sample.bpmn), two WorkItem configurations files (CustomWorkItem.conf and drools.rulebase.conf), WorkItem implementation class (HelloProcessExtension.java) and test class (ProcessTest.java).
These files can be imported into a 'HelloProcess' project as shown below.
After running the test class 'ProcessTest.java', following results can be seen.
Here are the main steps involved in creating the custom WorkItem.
1.) Workitem definition: Create the definition of the workitem using properties that are name-value pairs in a file CustomWorkItem.conf.
"name" : "HelloProcessExtension",
"icon" : "icons/action.gif",
"displayName" : "HelloProcessExtension"
This definition file (CustomWorkItem.conf) is located in META-INF directory.
2.) WorkItem registration:
The definition of the workitem (CustomWorkItem.conf) 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.workDefinitions = CustomWorkItem.conf WorkDefinitions.conf
3.) 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 in Step1 and Step2 (i.e, CustomWorkItem.conf 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.
'HelloProcesExtension' node can be created inside the process using drag and drop.
4.) A WorkItemHandler implementation class needs to be created for the 'HelloProcessExtension' node.
5.) The WorkItemHandler should be registered at the WorkItemManager, using API as shown below (in ProcessTest.java)