流程引擎对象和其配置对象都是activiti的核心对象
一、activiti的简单使用流程
activiti在工作时,一般有以下几个步骤:
创建一个流程引擎配置对象ProcessEngineConfiguration对流程引擎进行配置 通过流程引擎配置对象来获取流程引擎对象ProcessEngine 通过流程引擎对象来部署流程图 启动流程二、流程引擎配置对象ProcessEngineConfiguration的介绍
activiti用ProcessEngineConfiguration对象来配置流程引擎。ProcessEngineConfiguration类提供了多个创建该类对象的静态方法,可以读取相应的配置文件,返回ProcessEngineConfiguration实例。通过该类中提供的getter和setter方法可以对流程引擎配置对象进行配置。
三、activiti配置文件的介绍
activiti创建流程引擎配置对象时需要一个配置文件,
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!-- 配置使用默认bean名称的流程引擎配置对象 -->
<bean id="processEngineConfiguration"
class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcDriver" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti_01"></property>
<property name="jdbcUsername" value="root"></property>
<property name="jdbcPassword" value="root"></property>
<property name="databaseSchemaUpdate" value="true"></property>
</bean>
</beans>
仔细观察这个配置文件,这其实是一个spring的配置文件,在其中配置了一个ProcessEngineConfiguration类的bean,然后在代码中就可以读取这个配置文件,获取这个bean。
processEngineConfiguration这个bean要注入的属性:
(1)数据库连接相关的属性
(2)databaseSchemaUpdate,数据库策略,
false:默认值,设置为该值,activiti在启动时如果数据库中没有表或者版本不匹配,会抛出异常 true:启动时会对所有表进行更新,如果没有表就会自动创建表 create-drop: 启动时创建表,关闭时删除表针对其中的数据库连接相关的属性,我们还可以在这个配置文件中再配置一个数据源,在这里引用数据源的bean
<!-- 配置连接池 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="com.mysql.jdbc.Driver"/> <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti_01"/> <property name="user" value="root"/> <property name="password" value="root"/> </bean>










