流程引擎管理类获取集合演示
流程引擎插件原理分析及使用
手工创建流程引擎3种方式
标准版流程引擎类扩展思路
1 继承StandaloneProcessEngineConfiguration
public class GjfStandaloneProcessConfiguration extends StandaloneProcessEngineConfiguration {
@Override
protected void init() {
System.out.println("###########GjfStandaloneProcessConfiguration init ###########");
super.init();
}
}
2 配置Bean
<bean id="processEngineConfiguration2"
class="com.gjf.chp_1.GjfStandaloneProcessConfiguration">
<property name="jdbcUrl" value="jdbc:mysql://106.13.133.106:3306/camunda"/>
<property name="jdbcDriver" value="com.mysql.jdbc.Driver"/>
<property name="jdbcUsername" value="root"/>
<property name="jdbcPassword" value="mysql2019"/>
<property name="databaseSchemaUpdate" value="true"/>
<property name="processEnginePlugins">
<list>
<bean id="gjfProcessEnginePlugins" class="com.gjf.chp_1.GjfProcessEnginePlugins"/>
</list>
</property>
</bean>
Spring整合Camunda
<bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
<property name="targetDataSource">
<bean class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<property name="url" value="jdbc:mysql://106.13.133.106:3306/camunda"/>
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<property name="username" value="root"/>
<property name="password" value="mysql2019"/>
</bean>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<bean id="processEngineConfiguration" class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource"></property>
<property name="databaseSchemaUpdate" value="true"></property>
<property name="historyLevel" value="HISTORY_LEVEL_AUDIT"></property>
<property name="transactionManager" ref="transactionManager"></property>
</bean>
<bean id="processEngine" class="org.camunda.bpm.engine.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration"/>
</bean>
<bean id="repositoryService" factory-bean="processEngineConfiguration" factory-method="getRepositoryService"/>
<bean id="runtimeService" factory-bean="processEngineConfiguration" factory-method="getRuntimeService"/>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
自动部署使用
<bean id="processEngineConfiguration" class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource"></property>
<property name="databaseSchemaUpdate" value="true"></property>
<property name="historyLevel" value="HISTORY_LEVEL_AUDIT"></property>
<property name="transactionManager" ref="transactionManager"></property>
<!-- 自动部署-->
<property name="deploymentResources" value="classpath*:*.bpmn"></property>
<!-- 配置租户-->
<property name="deploymentTenantId" value="A系统"></property>
<!-- 文档存在,不在部署-->
<property name="deployChangedOnly" value="true"></property>
</bean>
Spring风格流程引擎类扩展
继承SpringProcessEngineConfiguration
public class GjfSpringProcessEngineConfiguration extends SpringProcessEngineConfiguration {
@Override
protected void init() {
System.out.println("########## GjfSpringProcessEngineConfiguration init 开始 ### ");
super.init();
System.out.println("########## GjfSpringProcessEngineConfiguration init 结束 ### ");
}
}
配置Bean
<bean id="processEngineConfiguration"
class="com.gjf.chp_1.spring.GjfSpringProcessEngineConfiguration">
...........
Camunda引擎数据库类型优化点
Q 不支持国产数据库
ProcessEngineConfigurationImpl 中数据库类型映射方法
protected static Properties getDefaultDatabaseTypeMappings() {
Properties databaseTypeMappings = new Properties();
databaseTypeMappings.setProperty("H2", "h2");
databaseTypeMappings.setProperty(MY_SQL_PRODUCT_NAME, "mysql");
databaseTypeMappings.setProperty(MARIA_DB_PRODUCT_NAME, "mariadb");
databaseTypeMappings.setProperty("Oracle", "oracle");
databaseTypeMappings.setProperty("PostgreSQL", "postgres");
databaseTypeMappings.setProperty("Microsoft SQL Server", "mssql");
databaseTypeMappings.setProperty("DB2", "db2");
databaseTypeMappings.setProperty("DB2", "db2");
databaseTypeMappings.setProperty("DB2/NT", "db2");
databaseTypeMappings.setProperty("DB2/NT64", "db2");
databaseTypeMappings.setProperty("DB2 UDP", "db2");
databaseTypeMappings.setProperty("DB2/LINUX", "db2");
databaseTypeMappings.setProperty("DB2/LINUX390", "db2");
databaseTypeMappings.setProperty("DB2/LINUXX8664", "db2");
databaseTypeMappings.setProperty("DB2/LINUXZ64", "db2");
databaseTypeMappings.setProperty("DB2/400 SQL", "db2");
databaseTypeMappings.setProperty("DB2/6000", "db2");
databaseTypeMappings.setProperty("DB2 UDB iSeries", "db2");
databaseTypeMappings.setProperty("DB2/AIX64", "db2");
databaseTypeMappings.setProperty("DB2/HPUX", "db2");
databaseTypeMappings.setProperty("DB2/HP64", "db2");
databaseTypeMappings.setProperty("DB2/SUN", "db2");
databaseTypeMappings.setProperty("DB2/SUN64", "db2");
databaseTypeMappings.setProperty("DB2/PTX", "db2");
databaseTypeMappings.setProperty("DB2/2", "db2");
return databaseTypeMappings;
}