작업 흐름 UserTask 사용
6015 단어 user
작업 흐름 설정:
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="Examples">
<process id="executionAndTaskListenerDelegation">
<!-- -->
<extensionElements>
<activiti:executionListener class="com.easyway.activiti.servicetask.FieldInjectedExecutionListener" event="start">
<activiti:field name="fixedValue" stringValue="Yes, I am " />
<activiti:field name="dynamicValue" expression="${sentenceGenerator.getSentence()}" />
</activiti:executionListener>
</extensionElements>
<startEvent id="start" />
<sequenceFlow id="flow1" sourceRef="start" targetRef="userTask" />
<!-- -->
<userTask id="userTask" name="Schedule meeting">
<extensionElements>
<activiti:executionListener event="start" delegateExpression="${myExecutionListenerBean}" />
<activiti:taskListener event="create" delegateExpression="${myTaskListenerBean}" />
</extensionElements>
</userTask>
<sequenceFlow id="flow3" sourceRef="userTask" targetRef="userTask3" />
<!-- -->
<userTask id="userTask3">
<extensionElements>
<activiti:executionListener expression="${myPojo.myMethod(execution.event)}" event="end" />
</extensionElements>
</userTask>
<sequenceFlow id="flow4" sourceRef="userTask3" targetRef="end" />
<endEvent id="end" />
</process>
</definitions>
코드:
package com.easyway.activiti.servicetask;
import org.activiti.engine.runtime.ProcessInstance;
/**
* 1. :
* <!-- -->
<extensionElements>
<activiti:executionListener class="com.easyway.activiti.servicetask.FieldInjectedExecutionListener" event="start">
<activiti:field name="fixedValue" stringValue="Yes, I am " />
<activiti:field name="dynamicValue" expression="${sentenceGenerator.getSentence()}" />
</activiti:executionListener>
</extensionElements>
2.
<userTask id="userTask" name="Schedule meeting">
<extensionElements>
<activiti:executionListener event="start" delegateExpression="${myExecutionListenerBean}" />
<activiti:taskListener event="create" delegateExpression="${myTaskListenerBean}" />
</extensionElements>
</userTask>
3.
<userTask id="userTask3">
<extensionElements>
<activiti:executionListener expression="${myPojo.myMethod(execution.event)}" event="end" />
</extensionElements>
</userTask>
* @author longgangbai
*
* 2011-12-20 09:30:42
*/
@ContextConfiguration("classpath:servicetaskSpringTest-context.xml")
public class ExecutionAndTaskListenerDelegationExpressionTest extends SpringActivitiTestCase {
@Deployment(resources={"diagrams/userTaskexecutionAndTaskListenerDelegationExpression.bpmn20.xml"})
public void testExecutionAndTaskListenerDelegationExpression() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("executionAndTaskListenerDelegation");
assertEquals("working", runtimeService.getVariable(processInstance.getId(), "executionListenerVar"));
assertEquals("working", runtimeService.getVariable(processInstance.getId(), "taskListenerVar"));
}
}
package com.easyway.activiti.servicetask;
import org.activiti.engine.delegate.DelegateExecution;
/**
* @author longgangbai
*
* 2011-12-20 10:55:06
*/
public class FieldInjectedExecutionListener implements ExecutionListener {
private Expression fixedValue;
private Expression dynamicValue;
/* (non-Javadoc)
* @see org.activiti.engine.delegate.ExecutionListener#notify(org.activiti.engine.delegate.DelegateExecution)
*/
@Override
public void notify(DelegateExecution execution) throws Exception {
execution.setVariable("var", fixedValue.getValue(execution).toString() + dynamicValue.getValue(execution).toString());
}
}
package com.easyway.activiti.servicetask;
import org.activiti.engine.delegate.DelegateExecution;
/**
*
* @author longgangbai
*
* 2011-12-20 09:32:45
*/
public class ActivitiExecutionListenerBean implements ExecutionListener {
public void notify(DelegateExecution execution) throws Exception {
execution.setVariable("executionListenerVar", "working");
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
ios background location updateAbout positioning There are three official recommendations The significant-change location service (Recommended) Foregro...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.