jBPM6: Custom work item handlers
scattie Feb 25, 2014 11:10 AMHello,
So I am looking at implementing a custom work item handler through the KIE-WB (jBPM 6), and I am kind of stumped on how to do so.
I have created a simple process in the web-designer with a single service task. Now I want this task to use my custom work item handler. How would I do this (through the web-console)?
I have already done the following:
- created a Java class implementing WorkItemHandler and created a JAR with this class
- added a work item definition to the process:
[
"name" : "CustomTestTask",
"parameters" : [
"aParam" : new StringDataType()
],
"results" : [
"id" : new StringDataType(),
],
"displayName" : "CustomTestTask",
"icon" : "defaultservicenodeicon.png"
]
Now, I assume I need to do the following now:
- add the JAR with the implementation as dependency to the BPM project
- "register" the custom handler
Adding the JAR as dependency shouldn't be too hard, I just need to know where exactly it should go.
Registering my custom handler class is something that completely eludes me, though. I've found some documentation advising me to adapt a conf file ("CustomWorkItemHandlers.conf") and then re-running the install.jBPM-console target on the build.xml script, but that doesn't seem like a very "clean" way. I'll be adding lots of custom handlers and I do not want to be reinstalling the jbpm-console each time. I've also found some Java code that is supposed to do it, by invoking ksession.getWorkItemManager().registerWorkItemHandler(), but then I am not sure where I am supposed to invoke this code from? I want to use a single, stateful ksession, so my handlers should be defined on start-up.
Preferrably, I'd like to do all of this through the web-console and not go fiddle in server XML or config files (that in my case are located on a remote server).
Any useful tips, or if anyone could point me to some relevant documentation?
EDIT:
Hmm. I found the "CustomWorkItemHandler.conf" file in the jbpm-console.war/WEB-INF/classes/META-INF in my server's deployment directory. I assume that I need to adapt this file to register my customer handler, however, I hope there is an easier way than to extract the WAR, adapt the file manually, re-package the WAR and restart the server? I hope this sort of thing can be registered through the web-console? Seems logical, as I would assume it is a commonly used function...
And where does the JAR go, that has the custom class? Also in the WAR?