数据库表命名规则:
Activiti工作流引擎的数据库表中的表名称都是以 ACT_.第二部分两个字母表示表的类型。使用模糊匹配的方式说明表的类型匹配activiti的服务API.
· ACT_RE_*: RE代表仓储(Repository).这种表前缀以“static”表示流程定义信息或者流程资源信息(如流程的图表和规则等).
· ACT_RU_*: RU标识为运行(Runtime)时表。包含流程实例,用户任务和变量任务等在运行时的数据信息。这些表只存储Activiti在流程实例运行执行的数据,在流程结束的时候从表中去除数据。从而保持运行时候数据的表的快速和小数据量.
· ACT_ID_*:ID标识为唯一(Identity)的。包含一些唯一的信息如用户,用户做等信息。
· ACT_HI_*:HI表示历史数据(History)表,包括过期的流程实例,过期的变量和过期的任务等。
· ACT_GE_*:GE表示公用(General data)的数据库表类型。
ProcessEngine接口中暴露了在BPMN和工作流中中所有操作的服务接口。
在工作流activiti流程引擎中可以通过activiti.cfg.xml配置。
ProcessEngineConfiguration配置一个流程引擎,在用户应用中创建一个流程引擎的可以通过多种方式:1.基于默认的配置文件创建一个流程引擎: ProcessEngine processEngine = ProcessEngineConfiguration
.createProcessEngineConfigurationFromResourceDefault()
.buildProcessEngine();
2.在缺少配置文件创建一个流程引擎ProcessEngine processEngine = ProcessEngineConfiguration
.createStandaloneProcessEngineConfiguration()
.buildProcessEngine();
3.获取一个默认的流程引擎ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine()
在工作流activiti的classpath路径中activiti.cfg.xml文件位于activiti-5.6\setup\files\cfg.activiti\standalone中。
Spring的配置内容如下:
<beans xmlns="http://www.springframework.org/schema/beans"
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">
<bean id="processEngineConfiguration"class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
<property name="jdbcDriver" value="org.h2.Driver" />
<property name="jdbcUsername" value="sa" />
<property name="jdbcPassword" value="" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="false" />
<property name="mailServerHost" value="mail.my-corp.com" />
<property name="mailServerPort" value="5025" />
</bean>
</beans>
备注:上面activiti.cfg.xml配置必须spring,但是activiti工作流对spring并不是必须的。
通过编程方式ProcessEngineConfiguration
1.使用配置文件
ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();
ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(String resource);
ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(String resource, String beanName);
ProcessEngineConfiguration.createProcessEngineConfigurationFromInputStream(InputStream inputStream);
ProcessEngineConfiguration.createProcessEngineConfigurationFromInputStream(InputStream inputStream, String beanName);
2.无配置 文件创建方式
ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
.setJdbcUrl("jdbc:h2:mem:my-own-db;DB_CLOSE_DELAY=1000")
.setJobExecutorActivate(true)
.buildProcessEngine();
this is a convience class for unit testing purposes. Activiti will take care of the transactions. An H2 in-memory database is used by default. The database will be created and dropped when the engine boots and shuts down. When using this, probably no additional configuration is needed (except when using for example the job executor or mail capabilities). ( 测试环境中使用)
org.activiti.spring.SpringProcessEngineConfiguration:
To be used when the process engine is used in a Spring environment. See the Spring integration sectionfor more information. (Spring环境中使用)
org.activiti.engine.impl.cfg.JtaProcessEngineConfiguration:
([EXPERIMENTAL]) to be used when the engine runs in standalone mode, with JTA transactions.(JPA环境中使用)