-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
qiujie
committed
Apr 28, 2024
1 parent
2a43bdd
commit effff2c
Showing
56 changed files
with
3,222 additions
and
588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
hrm/src/main/java/com/qiujie/config/DataSourceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
package com.qiujie.config; | ||
|
||
import org.activiti.api.runtime.shared.identity.UserGroupManager; | ||
import org.activiti.engine.cfg.ProcessEngineConfigurator; | ||
import org.activiti.engine.impl.persistence.StrongUuidGenerator; | ||
import org.activiti.spring.SpringAsyncExecutor; | ||
import org.activiti.spring.SpringProcessEngineConfiguration; | ||
import org.activiti.spring.boot.AbstractProcessEngineAutoConfiguration; | ||
import org.activiti.spring.boot.ActivitiProperties; | ||
import org.activiti.spring.boot.ProcessDefinitionResourceFinder; | ||
import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer; | ||
import org.activiti.spring.boot.process.validation.AsyncPropertyValidator; | ||
import org.activiti.spring.bpmn.parser.CloudActivityBehaviorFactory; | ||
import org.activiti.validation.ProcessValidatorImpl; | ||
import org.activiti.validation.validator.ValidatorSet; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.jdbc.DataSourceBuilder; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.transaction.PlatformTransactionManager; | ||
|
||
import javax.sql.DataSource; | ||
import java.io.IOException; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
|
||
@Configuration | ||
public class DataSourceConfig extends AbstractProcessEngineAutoConfiguration { | ||
|
||
@Primary | ||
@Bean | ||
@ConfigurationProperties(prefix = "spring.datasource.master") | ||
public DataSource masterDataSource() { | ||
return DataSourceBuilder.create().build(); | ||
} | ||
|
||
|
||
@Bean | ||
@ConfigurationProperties(prefix = "spring.datasource.activiti") | ||
public DataSource activitiDataSource() { | ||
return DataSourceBuilder.create().build(); | ||
} | ||
|
||
/** | ||
* activiti7的数据源配置 | ||
* @param transactionManager | ||
* @param springAsyncExecutor | ||
* @param activitiProperties | ||
* @param processDefinitionResourceFinder | ||
* @param processEngineConfigurationConfigurer | ||
* @param processEngineConfigurators | ||
* @param userGroupManager | ||
* @return | ||
* @throws IOException | ||
*/ | ||
@Bean | ||
public SpringProcessEngineConfiguration springProcessEngineConfiguration( | ||
PlatformTransactionManager transactionManager, | ||
SpringAsyncExecutor springAsyncExecutor, | ||
ActivitiProperties activitiProperties, | ||
ProcessDefinitionResourceFinder processDefinitionResourceFinder, | ||
@Autowired(required = false) ProcessEngineConfigurationConfigurer processEngineConfigurationConfigurer, | ||
@Autowired(required = false) List<ProcessEngineConfigurator> processEngineConfigurators, | ||
UserGroupManager userGroupManager) throws IOException { | ||
|
||
SpringProcessEngineConfiguration conf = new SpringProcessEngineConfiguration(); | ||
conf.setConfigurators(processEngineConfigurators); | ||
configureProcessDefinitionResources(processDefinitionResourceFinder, | ||
conf); | ||
conf.setDataSource(activitiDataSource()); | ||
conf.setTransactionManager(transactionManager); | ||
|
||
if (springAsyncExecutor != null) { | ||
conf.setAsyncExecutor(springAsyncExecutor); | ||
} | ||
conf.setDeploymentName(activitiProperties.getDeploymentName()); | ||
conf.setDatabaseSchema(activitiProperties.getDatabaseSchema()); | ||
conf.setDatabaseSchemaUpdate(activitiProperties.getDatabaseSchemaUpdate()); | ||
conf.setDbHistoryUsed(activitiProperties.isDbHistoryUsed()); | ||
conf.setAsyncExecutorActivate(activitiProperties.isAsyncExecutorActivate()); | ||
if (!activitiProperties.isAsyncExecutorActivate()) { | ||
ValidatorSet springBootStarterValidatorSet = new ValidatorSet("activiti-spring-boot-starter"); | ||
springBootStarterValidatorSet.addValidator(new AsyncPropertyValidator()); | ||
if (conf.getProcessValidator() == null) { | ||
ProcessValidatorImpl processValidator = new ProcessValidatorImpl(); | ||
processValidator.addValidatorSet(springBootStarterValidatorSet); | ||
conf.setProcessValidator(processValidator); | ||
} else { | ||
conf.getProcessValidator().getValidatorSets().add(springBootStarterValidatorSet); | ||
} | ||
} | ||
conf.setMailServerHost(activitiProperties.getMailServerHost()); | ||
conf.setMailServerPort(activitiProperties.getMailServerPort()); | ||
conf.setMailServerUsername(activitiProperties.getMailServerUserName()); | ||
conf.setMailServerPassword(activitiProperties.getMailServerPassword()); | ||
conf.setMailServerDefaultFrom(activitiProperties.getMailServerDefaultFrom()); | ||
conf.setMailServerUseSSL(activitiProperties.isMailServerUseSsl()); | ||
conf.setMailServerUseTLS(activitiProperties.isMailServerUseTls()); | ||
|
||
if (userGroupManager != null) { | ||
conf.setUserGroupManager(userGroupManager); | ||
} | ||
|
||
conf.setHistoryLevel(activitiProperties.getHistoryLevel()); | ||
conf.setCopyVariablesToLocalForTasks(activitiProperties.isCopyVariablesToLocalForTasks()); | ||
conf.setSerializePOJOsInVariablesToJson(activitiProperties.isSerializePOJOsInVariablesToJson()); | ||
conf.setJavaClassFieldForJackson(activitiProperties.getJavaClassFieldForJackson()); | ||
|
||
if (activitiProperties.getCustomMybatisMappers() != null) { | ||
conf.setCustomMybatisMappers(getCustomMybatisMapperClasses(activitiProperties.getCustomMybatisMappers())); | ||
} | ||
|
||
if (activitiProperties.getCustomMybatisXMLMappers() != null) { | ||
conf.setCustomMybatisXMLMappers(new HashSet<>(activitiProperties.getCustomMybatisXMLMappers())); | ||
} | ||
|
||
if (activitiProperties.getCustomMybatisXMLMappers() != null) { | ||
conf.setCustomMybatisXMLMappers(new HashSet<>(activitiProperties.getCustomMybatisXMLMappers())); | ||
} | ||
|
||
if (activitiProperties.isUseStrongUuids()) { | ||
conf.setIdGenerator(new StrongUuidGenerator()); | ||
} | ||
|
||
if (activitiProperties.getDeploymentMode() != null) { | ||
conf.setDeploymentMode(activitiProperties.getDeploymentMode()); | ||
} | ||
|
||
conf.setActivityBehaviorFactory(new CloudActivityBehaviorFactory()); | ||
|
||
if (processEngineConfigurationConfigurer != null) { | ||
processEngineConfigurationConfigurer.configure(conf); | ||
} | ||
|
||
return conf; | ||
} | ||
|
||
private void configureProcessDefinitionResources(ProcessDefinitionResourceFinder processDefinitionResourceFinder, | ||
SpringProcessEngineConfiguration conf) throws IOException { | ||
List<Resource> procDefResources = processDefinitionResourceFinder.discoverProcessDefinitionResources(); | ||
if (!procDefResources.isEmpty()) { | ||
conf.setDeploymentResources(procDefResources.toArray(new Resource[0])); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.