Java Code Examples for org.activiti.spring.SpringProcessEngineConfiguration#setTransactionManager()

The following examples show how to use org.activiti.spring.SpringProcessEngineConfiguration#setTransactionManager() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractProcessEngineConfiguration.java    From activiti6-boot2 with Apache License 2.0 7 votes vote down vote up
public SpringProcessEngineConfiguration processEngineConfigurationBean(Resource[] processDefinitions,
                                                                       DataSource dataSource,
                                                                       PlatformTransactionManager transactionManager,
                                                                       SpringAsyncExecutor springAsyncExecutor)
      throws IOException {

  SpringProcessEngineConfiguration engine = new SpringProcessEngineConfiguration();
  if (processDefinitions != null && processDefinitions.length > 0) {
    engine.setDeploymentResources(processDefinitions);
  }
  engine.setDataSource(dataSource);
  engine.setTransactionManager(transactionManager);

  if (null != springAsyncExecutor) {
    engine.setAsyncExecutor(springAsyncExecutor);
  }

  return engine;
}
 
Example 2
Source File: ActivitiConfig.java    From MicroCommunity with Apache License 2.0 6 votes vote down vote up
@Bean
public SpringProcessEngineConfiguration springProcessEngineConfiguration() {
    SpringProcessEngineConfiguration spec = new SpringProcessEngineConfiguration();
    spec.setDataSource(dataSource);
    spec.setTransactionManager(platformTransactionManager);
    spec.setDatabaseSchemaUpdate("true");
    spec.setActivityFontName("宋体");
    spec.setAnnotationFontName("宋体");
    spec.setLabelFontName("宋体");
    Resource[] resources = null;
    // 启动自动部署流程
    try {
        resources = new PathMatchingResourcePatternResolver().getResources("classpath*:processes/*.bpmn");
    } catch (IOException e) {
        e.printStackTrace();
    }
    spec.setDeploymentResources(resources);
    return spec;
}
 
Example 3
Source File: ActivitiDataSourceConfig.java    From opscenter with Apache License 2.0 5 votes vote down vote up
@Bean
public SpringProcessEngineConfiguration springProcessEngineConfiguration() {
    SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration();
    configuration.setDataSource(dataSource);
    configuration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
    configuration.setJobExecutorActivate(true);
    configuration.setTransactionManager(transactionManager());
    return configuration;
}
 
Example 4
Source File: SpringJmsConfig.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Bean
public SpringProcessEngineConfiguration processEngineConfiguration() {
  SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration();
  configuration.setDataSource(dataSource());
  configuration.setTransactionManager(transactionManager());
  configuration.setDatabaseSchemaUpdate(SpringProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
  configuration.setAsyncExecutorMessageQueueMode(true);
  configuration.setAsyncExecutorActivate(true);
  configuration.setJobManager(jobManager());
  return configuration;        
}
 
Example 5
Source File: JpaProcessEngineAutoConfiguration.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public SpringProcessEngineConfiguration springProcessEngineConfiguration(
        DataSource dataSource, EntityManagerFactory entityManagerFactory,
        PlatformTransactionManager transactionManager, SpringAsyncExecutor springAsyncExecutor) throws IOException {

  SpringProcessEngineConfiguration config = this.baseSpringProcessEngineConfiguration(dataSource, 
      transactionManager, springAsyncExecutor);
  config.setJpaEntityManagerFactory(entityManagerFactory);
  config.setTransactionManager(transactionManager);
  config.setJpaHandleTransaction(false);
  config.setJpaCloseEntityManager(false);
  return config;
}
 
Example 6
Source File: ServiceSpringModuleConfig.java    From herd with Apache License 2.0 4 votes vote down vote up
/**
 * Gets the Activiti Process Engine Configuration.
 *
 * @param activitiAsyncExecutor the async executor to set on the configuration.
 *
 * @return the Activiti Process Engine Configuration.
 */
@Bean
public SpringProcessEngineConfiguration activitiProcessEngineConfiguration(AsyncExecutor activitiAsyncExecutor)
{
    // Initialize a new process engine configuration for Activiti that is Spring enabled.
    SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration();

    // Share the herd data source and transaction manager with Activiti so all DB operations between the herd schema and the Activiti schema will occur
    // within the same transaction that can be committed or rolled back together.
    configuration.setDataSource(herdDataSource);
    configuration.setTransactionManager(herdTransactionManager);

    // Set the database schema update approach. This will be different for the main application and JUnits which is why we get it from a bean
    // via the method below.
    configuration.setDatabaseSchemaUpdate(getActivitiDbSchemaUpdateParamBeanName());

    // Enable the async executor so threads can be picked up and worked on.
    configuration.setAsyncExecutorActivate(true);

    // Explicitly wire in our "Spring" async executor which in turn is configured with our own task executor.
    configuration.setAsyncExecutorEnabled(true);
    configuration.setAsyncExecutor(activitiAsyncExecutor);

    // Set the allowed beans to an empty map so the Activiti workflows won't be able to call any arbitrary bean (e.g. services, etc.).
    configuration.setBeans(new HashMap<>());

    // Explicitly set a custom herd delegate interceptor that allows us to autowire in Spring beans onto our Java delegate tasks.
    configuration.setDelegateInterceptor(herdDelegateInterceptor);

    // Explicitly set a custom herd command invoker that allows us to perform specialized logging for asynchronous tasks.
    configuration.setCommandInvoker(herdCommandInvoker);

    // Initialize the scripting engines.
    initScriptingEngines(configuration);

    // Set the default "from" field for Activiti mail
    String mailServerDefaultFrom = configurationHelper.getProperty(ConfigurationValue.ACTIVITI_DEFAULT_MAIL_FROM);
    configuration.setMailServerDefaultFrom(mailServerDefaultFrom);
    // Set the mail server hostname for Activiti mail
    String mailServerHost = configurationHelper.getProperty(ConfigurationValue.ACTIVITI_MAIL_SERVER_HOST);
    configuration.setMailServerHost(mailServerHost);
    // Set the mail server port number for Activiti mail
    int mailServerPort = configurationHelper.getProperty(ConfigurationValue.ACTIVITI_MAIL_SERVER_PORT, Integer.class);
    configuration.setMailServerPort(mailServerPort);
    LOGGER.info("Activiti mail server configurations: activitiMailServerDefaultFrom=\"{}\" activitiMailServerHost=\"{}\" activitiMailServerPort={}",
        mailServerDefaultFrom, mailServerHost, mailServerPort);

    // Attach a custom herd process engine configurator that will allow us to modify the configuration before the engine is built.
    List<ProcessEngineConfigurator> herdConfigurators = new ArrayList<>();
    herdConfigurators.add(herdProcessEngineConfigurator);
    configuration.setConfigurators(herdConfigurators);

    // Return the configuration.
    return configuration;
}