`
longgangbai
  • 浏览: 7249151 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

工作流Activiti的学习总结(二)activiti中ProcessEngine的创建和数据库表命名规则

 
阅读更多

数据库表命名规则:

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和工作流中中所有操作的服务接口。

  • RuntimeService: 用户获取流程实例相关的各种运行时信息.
  • TaskService: 暴露服务用于操作人工操作的任务例如代办( claiming, completing and assigning tasks).
  • IdentityService: 这个服务用于管理用户和用户组已经用户和用户组关系等的。
  • ManagementService: 暴露引擎飞管理和主要操作。
  • HistoryService:服务暴露过期流程实例等信息。

 

在工作流activiti流程引擎中可以通过activiti.cfg.xml配置。

ProcessEngineConfiguration配置一个流程引擎,在用户应用中创建一个流程引擎的可以通过多种方式:

1.基于默认的配置文件创建一个流程引擎:

  ProcessEngine processEngine = ProcessEngineConfiguration
      .createProcessEngineConfigurationFromResourceDefault()
      .buildProcessEngine();
2.在缺少配置文件创建一个流程引擎

ProcessEngine processEngine = ProcessEngineConfiguration
      .createStandaloneProcessEngineConfiguration()
      .buildProcessEngine();
3.获取一个默认的流程引擎

ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine()
 
在工作流activiticlasspath路径中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();

 

org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration: 在独立方式运行的流程引擎使用。 Activiti需要使用事务对象。默认的情况下,在引擎启动的时候检查数据库将检查activiti的是否有schemaschema的版本是否正确. org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration:

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 section for more information. (Spring环境中使用)

 

org.activiti.engine.impl.cfg.JtaProcessEngineConfiguration:

     ([EXPERIMENTAL]) to be used when the engine runs in standalone mode, with JTA transactions.(JPA环境中使用)

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics