Activiti 读取并转换BPMN文件

读取并转换BPMN文件

统一的BPMN标准,对工作流的流程定义采用BPMN统一格式。如下是对该类型文件的解析工具类和方法。

核心代码块

  public static void bpmnMethod() throws XMLStreamException, IOException {
        File file = new File("E:/新建2.xml");
        InputStream inputStream = new FileInputStream(file);//实例化FileInputStream
        // InputStream inputStream = repositoryService.getResourceAsStream( processitionDefinition.getId(),sourceName);
        //创建转换对象
        BpmnXMLConverter converter = new BpmnXMLConverter();
        XMLInputFactory factory = XMLInputFactory.newInstance();
        XMLStreamReader reader = factory.createXMLStreamReader(inputStream);//createXmlStreamReader
        //将xml文件转换成BpmnModel
        BpmnModel bpmnModel = converter.convertToBpmnModel(reader);
        System.out.println();
    }

工具类BpmnXMLConverter 为activity jar包包含的内容。鉴于JDK版本原因,我采用的

      <!-- activiti5.18以上的版本至少需要jdk7 -->
        <dependency>
            <groupId>org.activiti</groupId>
            <artifactId>activiti-engine</artifactId>
            <version>5.18.0</version>
        </dependency>

XMLInputFactory为 javax.xml.stream的工具类。

以上。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值