当前位置:懂科普 >

IT科技

> java activiti

java activiti

<link rel="stylesheet" href="https://js.how234.com/third-party/SyntaxHighlighter/shCoreDefault.css" type="text/css" /><script type="text/javascript" src="https://js.how234.com/third-party/SyntaxHighlighter/shCore.js"></script><script type="text/javascript"> SyntaxHighlighter.all(); </script>

java activiti是什么,让我们一起了解一下?

Activiti项目是一项新的基于Apache许可的开源BPM平台,覆盖了业务流程管理、工作流、服务协作等领域的一个开源的、灵活的、易扩展的可执行流程语言框架,特色是提供了eclipse插件,开发人员可以通过插件直接绘画出业务。

Activiti执行的前期支持是什么?

1、首先我们要知道ProcessEngine对象,是Activiti工作的核心。负责生成流程运行时的各种实例及数据、监控和管理流程的运行。

2、然后是Activiti数据库支持:

Activiti的后台是有数据库的支持,所有的表都以ACT_开头。 第二部分是表示表的用途的两个字母标识。 用途也和服务的API对应。

ACT_RE_*: 'RE'表示repository。 这个前缀的表包含了流程定义和流程静态资源 (图片,规则,等等)。

ACT_RU_*: 'RU'表示runtime。 这些运行时的表,包含流程实例,任务,变量,异步任务,等运行中的数据。 Activiti只在流程实例执行过程中保存这些数据, 在流程结束时就会删除这些记录。 这样运行时表可以一直很小速度很快。

ACT_ID_*: 'ID'表示identity。 这些表包含身份信息,比如用户,组等等。

ACT_HI_*: 'HI'表示history。 这些表包含历史数据,比如历史流程实例, 变量,任务等等。

ACT_GE_*: 通用数据, 用于不同场景下,如存放资源文件。

java activiti

那么java中如何执行activiti?

说明:自定义一个简单流程,然后在main中直接通过控制台输入信息然后控制流程。

1、创建一个maven项目 引入依赖:pom.xml

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">    <modelVersion>4.0.0</modelVersion>    <parent>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-parent</artifactId>        <version>1.5.10.RELEASE</version>    </parent>    <groupId>com.jy.activiti</groupId>    <artifactId>activiti6-helloworld</artifactId>    <version>1.0-SNAPSHOT</version>    <dependencies>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter</artifactId>        </dependency>        <!--activiti 引擎-->        <dependency>            <groupId>org.activiti</groupId>            <artifactId>activiti-engine</artifactId>            <version>6.0.0</version>        </dependency>        <!-- junit 测试 -->        <dependency>            <groupId>junit</groupId>            <artifactId>junit</artifactId>            <version>4.11</version>            <scope>test</scope>        </dependency>        <!-- 日志-->        <dependency>            <groupId>ch.qos.logback</groupId>            <artifactId>logback-classic</artifactId>            <version>1.1.11</version>        </dependency>        <!--工具类 -->        <dependency>            <groupId>com.google.guava</groupId>            <artifactId>guava</artifactId>            <version>23.0</version>        </dependency>        <!-- 数据看看-->        <dependency>            <groupId>com.h2database</groupId>            <artifactId>h2</artifactId>            <version>1.3.176</version>        </dependency>    </dependencies>    <build>        <plugins>            <plugin>                <groupId>org.springframework.boot</groupId>                <artifactId>spring-boot-maven-plugin</artifactId>            </plugin>        </plugins>    </build></project>

2、添加流程模板文件:MyProcess.bpmn

<?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="second_approve" name="二级审批" isExecutable="true">    <startEvent id="startevent" name="开始"></startEvent>    <userTask id="submitForm" name="填写审批信息">      <extensionElements>        <activiti:formProperty id="message" name="申请信息" type="string" required="true"></activiti:formProperty>        <activiti:formProperty id="name" name="申请人姓名" type="string"></activiti:formProperty>        <activiti:formProperty id="submitTime" name="提交时间" type="date" datePattern="yyyy-MM-dd" required="true"></activiti:formProperty>        <activiti:formProperty id="submitType" name="确认申请" type="string" required="true"></activiti:formProperty>      </extensionElements>    </userTask>    <sequenceFlow id="flow1" sourceRef="startevent" targetRef="submitForm"></sequenceFlow>    <exclusiveGateway id="decideSubmit" name="提交或取消"></exclusiveGateway>    <sequenceFlow id="flow2" sourceRef="submitForm" targetRef="decideSubmit"></sequenceFlow>    <userTask id="ti_approve" name="主管审批">      <extensionElements>        <activiti:formProperty id="tlApprove" name="主管审批结果" type="string"></activiti:formProperty>        <activiti:formProperty id="tlMessage" name="主管备注" type="string" required="true"></activiti:formProperty>      </extensionElements>    </userTask>    <sequenceFlow id="flow3" sourceRef="decideSubmit" targetRef="ti_approve">      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${submitType=="y"||submitType=="Y"}]]></conditionExpression>    </sequenceFlow>    <exclusiveGateway id="decideTLapprove" name="主管审批校验"></exclusiveGateway>    <sequenceFlow id="flow4" sourceRef="ti_approve" targetRef="decideTLapprove"></sequenceFlow>    <userTask id="hr_approve" name="人事审批">      <extensionElements>        <activiti:formProperty id="hrApprove" name="人事审批结果" type="string" required="true"></activiti:formProperty>        <activiti:formProperty id="hrMessage" name="人事备注" type="string" required="true"></activiti:formProperty>      </extensionElements>    </userTask>    <sequenceFlow id="flow5" sourceRef="decideTLapprove" targetRef="hr_approve">      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${tlApprove=="y"||tlApprove=="Y"}]]></conditionExpression>    </sequenceFlow>    <endEvent id="endeventCancle" name="取消"></endEvent>    <sequenceFlow id="flow7" sourceRef="decideSubmit" targetRef="endeventCancle">      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${submitType=="n"||submitType=="N"}]]></conditionExpression>    </sequenceFlow>    <sequenceFlow id="flow9" sourceRef="decideTLapprove" targetRef="submitForm"></sequenceFlow>    <exclusiveGateway id="hrDecideApprove" name="人事审批校验"></exclusiveGateway>    <sequenceFlow id="flow10" sourceRef="hr_approve" targetRef="hrDecideApprove"></sequenceFlow>    <endEvent id="endevent" name="结束"></endEvent>    <sequenceFlow id="flow11" sourceRef="hrDecideApprove" targetRef="endeventCancle">      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${hrApprove=="y"||hrApprove=="Y"}]]></conditionExpression>    </sequenceFlow>    <sequenceFlow id="flow12" sourceRef="hrDecideApprove" targetRef="submitForm"></sequenceFlow>  </process>  <bpmndi:BPMNDiagram id="BPMNDiagram_second_approve">    <bpmndi:BPMNPlane bpmnElement="second_approve" id="BPMNPlane_second_approve">      <bpmndi:BPMNShape bpmnElement="startevent" id="BPMNShape_startevent">        <omgdc:Bounds height="35.0" width="35.0" x="200.0" y="230.0"></omgdc:Bounds>      </bpmndi:BPMNShape>      <bpmndi:BPMNShape bpmnElement="submitForm" id="BPMNShape_submitForm">        <omgdc:Bounds height="55.0" width="105.0" x="280.0" y="220.0"></omgdc:Bounds>      </bpmndi:BPMNShape>      <bpmndi:BPMNShape bpmnElement="decideSubmit" id="BPMNShape_decideSubmit">        <omgdc:Bounds height="40.0" width="40.0" x="430.0" y="228.0"></omgdc:Bounds>      </bpmndi:BPMNShape>      <bpmndi:BPMNShape bpmnElement="ti_approve" id="BPMNShape_ti_approve">        <omgdc:Bounds height="55.0" width="105.0" x="515.0" y="221.0"></omgdc:Bounds>      </bpmndi:BPMNShape>      <bpmndi:BPMNShape bpmnElement="decideTLapprove" id="BPMNShape_decideTLapprove">        <omgdc:Bounds height="40.0" width="40.0" x="665.0" y="229.0"></omgdc:Bounds>      </bpmndi:BPMNShape>      <bpmndi:BPMNShape bpmnElement="hr_approve" id="BPMNShape_hr_approve">        <omgdc:Bounds height="55.0" width="105.0" x="750.0" y="222.0"></omgdc:Bounds>      </bpmndi:BPMNShape>      <bpmndi:BPMNShape bpmnElement="endeventCancle" id="BPMNShape_endeventCancle">        <omgdc:Bounds height="35.0" width="35.0" x="540.0" y="310.0"></omgdc:Bounds>      </bpmndi:BPMNShape>      <bpmndi:BPMNShape bpmnElement="hrDecideApprove" id="BPMNShape_hrDecideApprove">        <omgdc:Bounds height="40.0" width="40.0" x="900.0" y="230.0"></omgdc:Bounds>      </bpmndi:BPMNShape>      <bpmndi:BPMNShape bpmnElement="endevent" id="BPMNShape_endevent">        <omgdc:Bounds height="35.0" width="35.0" x="985.0" y="233.0"></omgdc:Bounds>      </bpmndi:BPMNShape>      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">        <omgdi:waypoint x="235.0" y="247.0"></omgdi:waypoint>        <omgdi:waypoint x="280.0" y="247.0"></omgdi:waypoint>      </bpmndi:BPMNEdge>      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">        <omgdi:waypoint x="385.0" y="247.0"></omgdi:waypoint>        <omgdi:waypoint x="430.0" y="248.0"></omgdi:waypoint>      </bpmndi:BPMNEdge>      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">        <omgdi:waypoint x="470.0" y="248.0"></omgdi:waypoint>        <omgdi:waypoint x="515.0" y="248.0"></omgdi:waypoint>      </bpmndi:BPMNEdge>      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">        <omgdi:waypoint x="620.0" y="248.0"></omgdi:waypoint>        <omgdi:waypoint x="665.0" y="249.0"></omgdi:waypoint>      </bpmndi:BPMNEdge>      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">        <omgdi:waypoint x="705.0" y="249.0"></omgdi:waypoint>        <omgdi:waypoint x="750.0" y="249.0"></omgdi:waypoint>      </bpmndi:BPMNEdge>      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">        <omgdi:waypoint x="450.0" y="268.0"></omgdi:waypoint>        <omgdi:waypoint x="450.0" y="327.0"></omgdi:waypoint>        <omgdi:waypoint x="540.0" y="327.0"></omgdi:waypoint>      </bpmndi:BPMNEdge>      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">        <omgdi:waypoint x="685.0" y="269.0"></omgdi:waypoint>        <omgdi:waypoint x="684.0" y="380.0"></omgdi:waypoint>        <omgdi:waypoint x="522.0" y="380.0"></omgdi:waypoint>        <omgdi:waypoint x="332.0" y="380.0"></omgdi:waypoint>        <omgdi:waypoint x="332.0" y="275.0"></omgdi:waypoint>      </bpmndi:BPMNEdge>      <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">        <omgdi:waypoint x="855.0" y="249.0"></omgdi:waypoint>        <omgdi:waypoint x="900.0" y="250.0"></omgdi:waypoint>      </bpmndi:BPMNEdge>      <bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">        <omgdi:waypoint x="920.0" y="270.0"></omgdi:waypoint>        <omgdi:waypoint x="557.0" y="310.0"></omgdi:waypoint>      </bpmndi:BPMNEdge>      <bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">        <omgdi:waypoint x="920.0" y="230.0"></omgdi:waypoint>        <omgdi:waypoint x="919.0" y="177.0"></omgdi:waypoint>        <omgdi:waypoint x="629.0" y="177.0"></omgdi:waypoint>        <omgdi:waypoint x="332.0" y="177.0"></omgdi:waypoint>        <omgdi:waypoint x="332.0" y="220.0"></omgdi:waypoint>      </bpmndi:BPMNEdge>    </bpmndi:BPMNPlane>  </bpmndi:BPMNDiagram></definitions>



标签: java activiti
  • 文章版权属于文章作者所有,转载请注明 https://dongkepu.com/itkeji/rjo3v4.html