Activiti7.1.0.M6中,SequenceFlow标签可以通过扩展BPMNXMLConverter来新增自定义属性
时间: 2024-02-18 17:02:02 浏览: 278
是的,SequenceFlow标签可以通过扩展BPMNXMLConverter来新增自定义属性。
在 Activiti7.1.0.M6 版本中,SequenceFlow 标签可以通过扩展 BPMNXMLConverter 类来新增自定义属性。具体做法如下:
1. 创建一个类,继承自 org.activiti.bpmn.converter.BPMNXMLConverter 类。
2. 重写 convertToXML 方法,在该方法中添加自定义属性。
3. 在 Activiti7 的配置文件中配置自定义的 BPMNXMLConverter 类。
例如,我们可以创建一个 CustomBPMNXMLConverter 类来添加自定义属性,具体代码如下:
```
public class CustomBPMNXMLConverter extends BPMNXMLConverter {
@Override
protected void convertSequenceflow(XMLStreamReader xtr, BpmnModel model, Process activeProcess) throws Exception {
super.convertSequenceflow(xtr, model, activeProcess);
SequenceFlow sequenceFlow = (SequenceFlow) model.getFlowElement(findCurrentFlowElement(xtr));
//添加自定义属性
sequenceFlow.setCustomProperty("myCustomProperty", "customValue");
}
}
```
然后,在 Activiti7 的配置文件中配置 CustomBPMNXMLConverter,具体配置如下:
```
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="customPostBPMNParseListeners">
<list>
<bean class="org.activiti.engine.impl.bpmn.parser.factory.DefaultBpmnParseFactory">
<property name="bpmnParser">
<bean class="org.activiti.bpmn.converter.BpmnXMLConverter">
<property name="converters">
<list>
<bean class="org.activiti.bpmn.converter.StartEventXMLConverter"/>
<bean class="org.activiti.bpmn.converter.EndEventXMLConverter"/>
<bean class="org.activiti.bpmn.converter.SequenceFlowXMLConverter"/>
<bean class="org.activiti.bpmn.converter.ThrowEventXMLConverter"/>
<bean class="org.activiti.bpmn.converter.BusinessRuleTaskXMLConverter"/>
<bean class="org.activiti.bpmn.converter.MailTaskXMLConverter"/>
<bean class="org.activiti.bpmn.converter.ManualTaskXMLConverter"/>
<bean class="org.activiti.bpmn.converter.ReceiveTaskXMLConverter"/>
<bean class="org.activiti.bpmn.converter.ScriptTaskXMLConverter"/>
<bean class="org.activiti.bpmn.converter.ServiceTaskXMLConverter"/>
<bean class="org.activiti.bpmn.converter.UserTaskXMLConverter"/>
<bean class="org.activiti.bpmn.converter.CallActivityXMLConverter"/>
<bean class="org.activiti.bpmn.converter.SubProcessXMLConverter"/>
<bean class="org.activiti.bpmn.converter.EventGatewayXMLConverter"/>
<bean class="org.activiti.bpmn.converter.ExclusiveGatewayXMLConverter"/>
<bean class="org.activiti.bpmn.converter.InclusiveGatewayXMLConverter"/>
<bean class="org.activiti.bpmn.converter.ParallelGatewayXMLConverter"/>
<bean class="org.activiti.bpmn.converter.TransactionXMLConverter"/>
<bean class="com.example.CustomBPMNXMLConverter"/> <!-- 添加自定义的 BPMNXMLConverter -->
</list>
</property>
</bean>
</property>
</bean>
</list>
</property>
</bean>
```
这样,我们就可以通过扩展 BPMNXMLConverter 类来新增自定义属性了。
阅读全文