Assuming you have Eclipse and the jbpm dependencies installed correctly via maven you can create custom work items with the following steps:
#1 Under src/main/resources/ in your eclipse project create a file called "CustomWorkItem.wid" where you put your custom workitem definition:
import org.drools.process.core.datatype.impl.type.StringDataType;
[
[
"name" : "CustomWorkItem",
"parameters" : [
"keywords" : new StringDataType(),
"limit" : new StringDataType()
],
"displayName" : "CustomWorkItem"
]
]
#2 Create another file called "drools.rulebase.conf" in the same directory where you register your custom workitem definition like so:
drools.workDefinitions = CustomWorkItem.wid WorkDefinitions.conf
#3 Create a java class that implements the Interface "WorkItemHandler" from the package "org.kie.api.runtime.process.WorkItemHandler". You will get the following two method stubs from the interface:
public void abortWorkItem(WorkItem workItem, WorkItemManager manager) { }
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) { }
The executeWorkItem method will be called by the bpm engine when the business process reaches your custom work item handler.
#4 Register your custom WorktItemHandler class with the bpm engine:
kSession.getWorkItemManager().registerWorkItemHandler("CustomWorkItem", new CustomWorkItemHandler());
Note that the first parameter should match the name from the work item definition and the second parameter should be a new instance of your custom work itemhandler java class created in step #3.
#5 Restart eclipse and use the new custom work item as a task in your business process!
The easiest way to get started with JBoss Tools is to use JBoss Developer Studio, which includes an installer for JBoss Tools and all its requirements. Choose one of these versions:
If you already use Eclipse, you can install the JBoss Tools plugins into your existing Fedora Eclipse 3.4, Eclipse 3.4.2, Eclipse Ganymede JEE SR2 Bundle (also here), or Eclipse Ganymede BIRT bundleusing these update sites.See the complete list here or here In order to resolve all the requirements, you may need to add or enable the both of the following other update sites within Eclipse.
That's it!