在Activiti中,可以通過BPMN文件或Java代碼來定義和使用數據對象和變量。
<itemDefinition id="stringItem" structureRef="xsd:string" />
<property name="myData" itemSubjectRef="stringItem" />
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess");
processInstance.setVariable("myVariable", "Hello World");
<sequenceFlow id="flow1" sourceRef="startEvent" targetRef="task1">
<conditionExpression xsi:type="tFormalExpression">${myVariable == 'Hello World'}</conditionExpression>
</sequenceFlow>
通過定義數據對象和變量,可以在Activiti中實現業務流程中的數據傳遞和處理邏輯。