流程引擎管理类获取集合演示

image.png

流程引擎插件原理分析及使用

image.png

手工创建流程引擎3种方式

image.png

标准版流程引擎类扩展思路

1 继承StandaloneProcessEngineConfiguration

  1. public class GjfStandaloneProcessConfiguration extends StandaloneProcessEngineConfiguration {
  2. @Override
  3. protected void init() {
  4. System.out.println("###########GjfStandaloneProcessConfiguration init ###########");
  5. super.init();
  6. }
  7. }

2 配置Bean

  1. <bean id="processEngineConfiguration2"
  2. class="com.gjf.chp_1.GjfStandaloneProcessConfiguration">
  3. <property name="jdbcUrl" value="jdbc:mysql://106.13.133.106:3306/camunda"/>
  4. <property name="jdbcDriver" value="com.mysql.jdbc.Driver"/>
  5. <property name="jdbcUsername" value="root"/>
  6. <property name="jdbcPassword" value="mysql2019"/>
  7. <property name="databaseSchemaUpdate" value="true"/>
  8. <property name="processEnginePlugins">
  9. <list>
  10. <bean id="gjfProcessEnginePlugins" class="com.gjf.chp_1.GjfProcessEnginePlugins"/>
  11. </list>
  12. </property>
  13. </bean>

Spring整合Camunda

  1. <bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
  2. <property name="targetDataSource">
  3. <bean class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
  4. <property name="url" value="jdbc:mysql://106.13.133.106:3306/camunda"/>
  5. <property name="driverClass" value="com.mysql.jdbc.Driver"/>
  6. <property name="username" value="root"/>
  7. <property name="password" value="mysql2019"/>
  8. </bean>
  9. </property>
  10. </bean>
  11. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  12. <property name="dataSource" ref="dataSource"></property>
  13. </bean>
  14. <bean id="processEngineConfiguration" class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration">
  15. <property name="dataSource" ref="dataSource"></property>
  16. <property name="databaseSchemaUpdate" value="true"></property>
  17. <property name="historyLevel" value="HISTORY_LEVEL_AUDIT"></property>
  18. <property name="transactionManager" ref="transactionManager"></property>
  19. </bean>
  20. <bean id="processEngine" class="org.camunda.bpm.engine.spring.ProcessEngineFactoryBean">
  21. <property name="processEngineConfiguration" ref="processEngineConfiguration"/>
  22. </bean>
  23. <bean id="repositoryService" factory-bean="processEngineConfiguration" factory-method="getRepositoryService"/>
  24. <bean id="runtimeService" factory-bean="processEngineConfiguration" factory-method="getRuntimeService"/>

image.png
image.png

  1. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  2. <property name="dataSource" ref="dataSource"></property>
  3. </bean>

自动部署使用

image.png
image.png

  1. <bean id="processEngineConfiguration" class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration">
  2. <property name="dataSource" ref="dataSource"></property>
  3. <property name="databaseSchemaUpdate" value="true"></property>
  4. <property name="historyLevel" value="HISTORY_LEVEL_AUDIT"></property>
  5. <property name="transactionManager" ref="transactionManager"></property>
  6. <!-- 自动部署-->
  7. <property name="deploymentResources" value="classpath*:*.bpmn"></property>
  8. <!-- 配置租户-->
  9. <property name="deploymentTenantId" value="A系统"></property>
  10. <!-- 文档存在,不在部署-->
  11. <property name="deployChangedOnly" value="true"></property>
  12. </bean>

Spring风格流程引擎类扩展

image.png

继承SpringProcessEngineConfiguration

  1. public class GjfSpringProcessEngineConfiguration extends SpringProcessEngineConfiguration {
  2. @Override
  3. protected void init() {
  4. System.out.println("########## GjfSpringProcessEngineConfiguration init 开始 ### ");
  5. super.init();
  6. System.out.println("########## GjfSpringProcessEngineConfiguration init 结束 ### ");
  7. }
  8. }

配置Bean

  1. <bean id="processEngineConfiguration"
  2. class="com.gjf.chp_1.spring.GjfSpringProcessEngineConfiguration">
  3. ...........

Camunda引擎数据库类型优化点

Q 不支持国产数据库

ProcessEngineConfigurationImpl 中数据库类型映射方法

  1. protected static Properties getDefaultDatabaseTypeMappings() {
  2. Properties databaseTypeMappings = new Properties();
  3. databaseTypeMappings.setProperty("H2", "h2");
  4. databaseTypeMappings.setProperty(MY_SQL_PRODUCT_NAME, "mysql");
  5. databaseTypeMappings.setProperty(MARIA_DB_PRODUCT_NAME, "mariadb");
  6. databaseTypeMappings.setProperty("Oracle", "oracle");
  7. databaseTypeMappings.setProperty("PostgreSQL", "postgres");
  8. databaseTypeMappings.setProperty("Microsoft SQL Server", "mssql");
  9. databaseTypeMappings.setProperty("DB2", "db2");
  10. databaseTypeMappings.setProperty("DB2", "db2");
  11. databaseTypeMappings.setProperty("DB2/NT", "db2");
  12. databaseTypeMappings.setProperty("DB2/NT64", "db2");
  13. databaseTypeMappings.setProperty("DB2 UDP", "db2");
  14. databaseTypeMappings.setProperty("DB2/LINUX", "db2");
  15. databaseTypeMappings.setProperty("DB2/LINUX390", "db2");
  16. databaseTypeMappings.setProperty("DB2/LINUXX8664", "db2");
  17. databaseTypeMappings.setProperty("DB2/LINUXZ64", "db2");
  18. databaseTypeMappings.setProperty("DB2/400 SQL", "db2");
  19. databaseTypeMappings.setProperty("DB2/6000", "db2");
  20. databaseTypeMappings.setProperty("DB2 UDB iSeries", "db2");
  21. databaseTypeMappings.setProperty("DB2/AIX64", "db2");
  22. databaseTypeMappings.setProperty("DB2/HPUX", "db2");
  23. databaseTypeMappings.setProperty("DB2/HP64", "db2");
  24. databaseTypeMappings.setProperty("DB2/SUN", "db2");
  25. databaseTypeMappings.setProperty("DB2/SUN64", "db2");
  26. databaseTypeMappings.setProperty("DB2/PTX", "db2");
  27. databaseTypeMappings.setProperty("DB2/2", "db2");
  28. return databaseTypeMappings;
  29. }