Jbpm6 service task execution java code

I'm new to jbpm6 My scenario is like this. I want to use jBPM service task to execute some java code From the documentation, I can't understand how to use domain specific processes and work item handlers in this type of code

Thank you first

Solution

Here's how to add a handler to the eclipse Maven project I call it the awesome handler, but you should choose a more specific name

1) First, in Src / main / resources / workitemdefinitions Create a work item definition file in wid My icon file is located in Src / main / resources

import org.drools.core.process.core.datatype.impl.type.StringDataType;

[
  [
    "name" : "Awesome","parameters" : [
      "Message1" : new StringDataType(),"Message2" : new StringDataType()
     ],"displayName" : "Awesome","icon" : "icon-info.gif"
  ]
]

2) In Src / main / resources / meta inf / customworkitemhandlers Create a work item handler configuration file in conf

[
  "Awesome": new org.jbpm.examples.util.handler.AwesomeHandler()
]

3) Create a drools session configuration file: Src / main / resources / meta inf / drools session. conf

drools.workItemHandlers = CustomWorkItemHandlers.conf

4) Create your handler to match the class you defined in step 2

public class AwesomeHandler implements WorkItemHandler {

    public AwesomeHandler() {
        super();
    }

    public void executeWorkItem(WorkItem workItem,WorkItemManager manager) {
        System.out.println("Executing Awesome handler");
        manager.completeWorkItem(workItem.getId(),null);
    }

    public void abortWorkItem(WorkItem workItem,WorkItemManager manager) {
        System.out.println("Aborting");
    }
}

5) After the handler is established, it must be registered in the session

//Get session
KieSession ksession = runtime.getKieSession();

//Register handlers
ksession.getWorkItemManager().registerWorkItemHandler("Awesome",new AwesomeHandler());

At this point, you should restart eclipse When eclipse opens, there should be a "custom tasks" tab in the palette It should contain an entry marked "awesome" with the specified icon

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>