@author YHC
首先描述一下版本:
activiti:Activiti5.10
mysql:5.5(Activiti有规定最低版本是5.1.11)
mysql驱动:mysql-connector-java-5.1.17-bin.jar
spring:3.1.2(也就是Activiti自带的例子中的jar包)
该示例主要是从Activiti官网的10分钟入门中提取的.
流程图:
对应的XML文件:(FinancialReportProcess.bpmn20.xml)
- xml version="1.0" encoding="UTF-8" ?>
- <definitions id="definitions"
- targetNamespace=""
- xmlns:activiti=""
- xmlns:bpmndi=""
- xmlns:omgdc=""
- xmlns:omgdi=""
- xmlns="">
-
- <process id="financialReport" name="Monthly financial report process">
-
- <startEvent id="theStart" />
-
- <sequenceFlow id="flow1" sourceRef="theStart" targetRef="writeReportTask" />
-
- <userTask id="writeReportTask" name="Write monthly financial report" >
- <documentation>
- Write monthly financial report for publication to shareholders.
- documentation>
- <potentialOwner>
- <resourceAssignmentExpression>
- <formalExpression>accountancyformalExpression>
- resourceAssignmentExpression>
- potentialOwner>
- userTask>
-
- <sequenceFlow id="flow2" sourceRef="writeReportTask" targetRef="verifyReportTask" />
-
- <userTask id="verifyReportTask" name="Verify monthly financial report" >
- <documentation>
- Verify monthly financial report composed by the accountancy department.
- This financial report is going to be sent to all the company shareholders.
- documentation>
- <potentialOwner>
- <resourceAssignmentExpression>
- <formalExpression>managementformalExpression>
- resourceAssignmentExpression>
- potentialOwner>
- userTask>
-
- <sequenceFlow id="flow3" sourceRef="verifyReportTask" targetRef="theEnd" />
-
- <endEvent id="theEnd" />
-
- process>
-
-
-
- <bpmndi:BPMNDiagram>
- <bpmndi:BPMNPlane bpmnElement="financialReport">
- <bpmndi:BPMNShape bpmnElement="theStart">
- <omgdc:Bounds height="30.0" width="30.0" x="75.0" y="225.0" />
- bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="writeReportTask">
- <omgdc:Bounds height="80.0" width="100.0" x="165.0" y="200.0" />
- bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="verifyReportTask">
- <omgdc:Bounds height="80.0" width="100.0" x="330.0" y="200.0" />
- bpmndi:BPMNShape>
- <bpmndi:BPMNShape bpmnElement="theEnd">
- <omgdc:Bounds height="28.0" width="28.0" x="480.0" y="226.0" />
- bpmndi:BPMNShape>
- <bpmndi:BPMNEdge bpmnElement="flow1">
- <omgdi:waypoint x="105.0" y="240.0" />
- <omgdi:waypoint x="165.0" y="240.0" />
- bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge bpmnElement="flow2">
- <omgdi:waypoint x="265.0" y="240.0" />
- <omgdi:waypoint x="330.0" y="240.0" />
- bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge bpmnElement="flow3">
- <omgdi:waypoint x="430.0" y="240.0" />
- <omgdi:waypoint x="480.0" y="240.0" />
- bpmndi:BPMNEdge>
- bpmndi:BPMNPlane>
- bpmndi:BPMNDiagram>
-
- definitions>
接下来看以下对应spring和数据库的配置文件:(activiti.cfg.xml)- xml version="1.0" encoding="UTF-8"?>
-
- <beans xmlns=""
- xmlns:context=""
- xmlns:tx=""
- xmlns:xsi=""
- xsi:schemaLocation=" /spring-beans.xsd
- /spring-context-2.5.xsd
- /spring-tx-3.0.xsd">
-
-
- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/activiti" />
- <property name="username" value="root" />
- <property name="password" value="root" />
- <property name="defaultAutoCommit" value="true" />
- bean>
-
-
-
- <bean id="transactionManager"
- class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource" />
- bean>
-
-
- <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
-
-
- <property name="databaseType" value="mysql">property>
- <property name="dataSource" ref="dataSource" />
- <property name="transactionManager" ref="transactionManager" />
- <property name="databaseSchemaUpdate" value="true" />
- <property name="jobExecutorActivate" value="false" />
-
- bean>
-
-
- <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
- <property name="processEngineConfiguration" ref="processEngineConfiguration" />
- bean>
-
-
- <bean id="repositoryService" factory-bean="processEngine"
- factory-method="getRepositoryService" />
- <bean id="runtimeService" factory-bean="processEngine"
- factory-method="getRuntimeService" />
- <bean id="taskService" factory-bean="processEngine"
- factory-method="getTaskService" />
- <bean id="historyService" factory-bean="processEngine"
- factory-method="getHistoryService" />
- <bean id="managementService" factory-bean="processEngine"
- factory-method="getManagementService" />
-
-
- <tx:annotation-driven transaction-manager="transactionManager"/>
-
-
- beans>
所需jar包均是从Activiti提供的Demo中的activiti-spring-examples项目libs-runtime下获取;
在测试的时候没有写junit单元测试,而是直接写的main方法.
下面介绍一下Activiti提供的可视化测试的环境:点击到页面上之后下载这一项:
1.解压文件
2.启动h2数据库,如下图:
3.启动tomcat,如下图
4.打开浏览器输入:
5.使用下面给出账户登录,如下图
6.部署一个新的流程,如下图操作:(请按照A,B顺序操作)
7.选择文件,如下图:
7.选择以下文件上传,如下图:(在7.1处描述文件位置)
7.1文件位置,如下图:
8.退出切换用户fozzie/fozzie登录
9.打开流程,选择流程,
10.启动此流程,注意:是紧接着上一步的操作:
11.查看任务,如下图
12.接受任务,如下图:
13,查看并完成任务,如下图
14.切换用户,kermit/kermit登陆.
15.查看任务.,如下图:
16.接受任务.如下图:
17.完成任务:如下图
18.确认是否有当前执行流程.来确认流程是否执行完毕.
阅读(1504) | 评论(0) | 转发(0) |