我正在使用一个简单的Hello world示例测试activiti中的服务任务。我创建了这个过程,它将在控制台中显示hello world,但是一旦我运行main,我什么都没有。
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="myProcess" name="My process" isExecutable="true">
<serviceTask id="servicetask1" name="Service Task" activiti:class="org.activiti.Test3"></serviceTask>
<startEvent id="startevent1" name="Start"></startEvent>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
<sequenceFlow id="flow2" sourceRef="servicetask1" targetRef="endevent1"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
<bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess">
<bpmndi:BPMNShape bpmnElement="servicetask1" id="BPMNShape_servicetask1">
<omgdc:Bounds height="55.0" width="105.0" x="370.0" y="130.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
<omgdc:Bounds height="35.0" width="35.0" x="210.0" y="140.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
<omgdc:Bounds height="35.0" width="35.0" x="660.0" y="140.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="245.0" y="157.0"></omgdi:waypoint>
<omgdi:waypoint x="370.0" y="157.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="475.0" y="157.0"></omgdi:waypoint>
<omgdi:waypoint x="660.0" y="157.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
公共课测试{
public static void main(String[] args) {
// TODO Auto-generated method stub
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment()
.addClasspathResource("org/activiti/test/yz.bpmn")
.deploy();
//starting it
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("employeeName", "Kermit");
variables.put("numberOfDays", new Integer(4));
variables.put("vacationMotivation", "I'm really tired!");
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess");
// Fetch all tasks for the management group
TaskService taskService = processEngine.getTaskService();
java.util.List<org.activiti.engine.task.Task> tasks = taskService.createTaskQuery().taskCandidateGroup("management").list();
for (org.activiti.engine.task.Task task : tasks) {
System.out.println("Task available: " + task.getName());
}
}
}
公共类Test3实现了JavaDelegate {
public void execute(DelegateExecution arg0) throws Exception {
System.out.println("tessssssssssssst");
}
}
答案 0 :(得分:1)
您可以使用以下内容,
public class Test3Delegate extends BaseJavaDelegate{
@Override
public void execute(DelegateExecution delegate) throws Exception
{
System.out.println("tessssssssssssst");
}
}
在bpmn文件中,您可以引用delegateExpression,
<serviceTask id="servicetask1" name="Service Task" activiti:delegateExpression="${Test3Delegate}"></serviceTask>
在模块上下文文件中,注册如下,
<bean id="Test3Delegate" parent="BaseJavaDelegate" class="package.name.Test3Delegate"></bean>
希望这会对你有所帮助。
答案 1 :(得分:0)
问题在于流程引擎配置