org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration Java Examples

The following examples show how to use org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration. 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: DefaultDatasourceConfiguration.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 6 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration configuration) {
  final DatabaseProperty database = camundaBpmProperties.getDatabase();

  configuration.setTransactionManager(transactionManager);

  if (camundaDataSource == null) {
    configuration.setDataSource(dataSource);
  } else {
    configuration.setDataSource(camundaDataSource);
  }

  configuration.setDatabaseType(database.getType());
  configuration.setDatabaseSchemaUpdate(database.getSchemaUpdate());

  if (!StringUtils.isEmpty(database.getTablePrefix())) {
    configuration.setDatabaseTablePrefix(database.getTablePrefix());
  }

  if(!StringUtils.isEmpty(database.getSchemaName())) {
    configuration.setDatabaseSchema(database.getSchemaName());
  }

  configuration.setJdbcBatchProcessing(database.isJdbcBatchProcessing());
}
 
Example #2
Source File: InMemProcessEngineConfiguration.java    From camunda-bpm-process-test-coverage with Apache License 2.0 6 votes vote down vote up
@Bean
public ProcessEngineConfigurationImpl processEngineConfiguration() throws Exception {

  SpringProcessWithCoverageEngineConfiguration config = new SpringProcessWithCoverageEngineConfiguration();

  
  try {
    Method setApplicationContext = SpringProcessEngineConfiguration.class.getDeclaredMethod("setApplicationContext", ApplicationContext.class);
    if (setApplicationContext != null) {
      setApplicationContext.invoke(config, applicationContext);
    }
  } catch (NoSuchMethodException e) {
    // expected for Camunda < 7.8.0
  }
  config.setExpressionManager(expressionManager());
  config.setTransactionManager(transactionManager());
  config.setDataSource(dataSource());
  config.setDatabaseSchemaUpdate("true");
  config.setHistory(ProcessEngineConfiguration.HISTORY_FULL);
  config.setJobExecutorActivate(false);
  config.init();
  return config;

}
 
Example #3
Source File: DefaultDatasourceConfiguration.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration configuration) {
  final DatabaseProperty database = camundaBpmProperties.getDatabase();

  configuration.setTransactionManager(transactionManager);

  if (camundaDataSource == null) {
    configuration.setDataSource(dataSource);
  } else {
    configuration.setDataSource(camundaDataSource);
  }

  configuration.setDatabaseType(database.getType());
  configuration.setDatabaseSchemaUpdate(database.getSchemaUpdate());

  if (!StringUtils.isEmpty(database.getTablePrefix())) {
    configuration.setDatabaseTablePrefix(database.getTablePrefix());
  }

  if(!StringUtils.isEmpty(database.getSchemaName())) {
    configuration.setDatabaseSchema(database.getSchemaName());
  }

  configuration.setJdbcBatchProcessing(database.isJdbcBatchProcessing());
}
 
Example #4
Source File: GenericPropertiesConfiguration.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration springProcessEngineConfiguration) {
  GenericProperties genericProperties = camundaBpmProperties.getGenericProperties();
  final Map<String, Object> properties = genericProperties.getProperties();

  if (!CollectionUtils.isEmpty(properties)) {
    ConfigurationPropertySource source = new MapConfigurationPropertySource(properties);
    Binder binder = new Binder(source);
    try {
      if (genericProperties.isIgnoreUnknownFields()) {
        binder.bind(ConfigurationPropertyName.EMPTY, Bindable.ofInstance(springProcessEngineConfiguration));
      } else {
        binder.bind(ConfigurationPropertyName.EMPTY, Bindable.ofInstance(springProcessEngineConfiguration), new NoUnboundElementsBindHandler(BindHandler.DEFAULT));
      }
    } catch (Exception e) {
      throw LOG.exceptionDuringBinding(e.getMessage());
    }
    logger.debug("properties bound to configuration: {}", genericProperties);
  }
}
 
Example #5
Source File: DefaultProcessEngineConfiguration.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
private void setProcessEngineName(SpringProcessEngineConfiguration configuration) {
  String processEngineName = StringUtils.trimAllWhitespace(camundaBpmProperties.getProcessEngineName());
  if (!StringUtils.isEmpty(processEngineName) && !processEngineName.contains("-")) {

    if (camundaBpmProperties.getGenerateUniqueProcessEngineName()) {
      if (!processEngineName.equals(ProcessEngines.NAME_DEFAULT)) {
        throw new RuntimeException(String.format("A unique processEngineName cannot be generated "
          + "if a custom processEngineName is already set: %s", processEngineName));
      }
      processEngineName = CamundaBpmProperties.getUniqueName(camundaBpmProperties.UNIQUE_ENGINE_NAME_PREFIX);
    }

    configuration.setProcessEngineName(processEngineName);
  } else {
    logger.warn("Ignoring invalid processEngineName='{}' - must not be null, blank or contain hyphen", camundaBpmProperties.getProcessEngineName());
  }
}
 
Example #6
Source File: GenericPropertiesConfiguration.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 6 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration springProcessEngineConfiguration) {
  GenericProperties genericProperties = camundaBpmProperties.getGenericProperties();
  final Map<String, Object> properties = genericProperties.getProperties();

  if (!CollectionUtils.isEmpty(properties)) {
    ConfigurationPropertySource source = new MapConfigurationPropertySource(properties);
    Binder binder = new Binder(source);
    try {
      if (genericProperties.isIgnoreUnknownFields()) {
        binder.bind(ConfigurationPropertyName.EMPTY, Bindable.ofInstance(springProcessEngineConfiguration));
      } else {
        binder.bind(ConfigurationPropertyName.EMPTY, Bindable.ofInstance(springProcessEngineConfiguration), new NoUnboundElementsBindHandler(BindHandler.DEFAULT));
      }
    } catch (Exception e) {
      throw LOG.exceptionDuringBinding(e.getMessage());
    }
    logger.debug("properties bound to configuration: {}", genericProperties);
  }
}
 
Example #7
Source File: DefaultProcessEngineConfiguration.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 6 votes vote down vote up
private void setProcessEngineName(SpringProcessEngineConfiguration configuration) {
  String processEngineName = StringUtils.trimAllWhitespace(camundaBpmProperties.getProcessEngineName());
  if (!StringUtils.isEmpty(processEngineName) && !processEngineName.contains("-")) {

    if (camundaBpmProperties.getGenerateUniqueProcessEngineName()) {
      if (!processEngineName.equals(ProcessEngines.NAME_DEFAULT)) {
        throw new RuntimeException(String.format("A unique processEngineName cannot be generated "
          + "if a custom processEngineName is already set: %s", processEngineName));
      }
      processEngineName = CamundaBpmProperties.getUniqueName(camundaBpmProperties.UNIQUE_ENGINE_NAME_PREFIX);
    }

    configuration.setProcessEngineName(processEngineName);
  } else {
    logger.warn("Ignoring invalid processEngineName='{}' - must not be null, blank or contain hyphen", camundaBpmProperties.getProcessEngineName());
  }
}
 
Example #8
Source File: CamundaBpmConfiguration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(ProcessEngineConfigurationImpl.class)
public ProcessEngineConfigurationImpl processEngineConfigurationImpl(List<ProcessEnginePlugin> processEnginePlugins) {
  final SpringProcessEngineConfiguration configuration = CamundaSpringBootUtil.springProcessEngineConfiguration();
  configuration.getProcessEnginePlugins().add(new CompositeProcessEnginePlugin(processEnginePlugins));
  return configuration;
}
 
Example #9
Source File: DefaultProcessEngineConfiguration.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
private void setDefaultSerializationFormat(SpringProcessEngineConfiguration configuration) {
  String defaultSerializationFormat = camundaBpmProperties.getDefaultSerializationFormat();
  if (StringUtils.hasText(defaultSerializationFormat)) {
    configuration.setDefaultSerializationFormat(defaultSerializationFormat);
  } else {
    logger.warn("Ignoring invalid defaultSerializationFormat='{}'", defaultSerializationFormat);
  }
}
 
Example #10
Source File: SpringBootProcessEnginePluginTest.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Test
public void delegate_for_springConfig() throws Exception {
  ProcessEngineConfigurationImpl c = new SpringProcessEngineConfiguration();

  DummySpringPlugin plugin = new DummySpringPlugin();

  plugin.preInit(c);
  plugin.postInit(c);

  assertThat(plugin.preInit).isTrue();
  assertThat(plugin.postInit).isTrue();
}
 
Example #11
Source File: GenericPropertiesConfigurationTest.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
  processEngineConfiguration = new SpringProcessEngineConfiguration();
  genericPropertiesConfiguration = new GenericPropertiesConfiguration();
  camundaBpmProperties = new CamundaBpmProperties();
  genericPropertiesConfiguration.camundaBpmProperties = camundaBpmProperties;
}
 
Example #12
Source File: EventPublisherPlugin.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration processEngineConfiguration) {

  if (!property.isTask() && !property.isExecution() && !property.isHistory()) {
    logger.info("EVENTING-002: Camunda Spring Boot Eventing Plugin is found, but disabled via property.");
    return;
  }

  if (property.isTask() || property.isExecution()) {

    logger.info("EVENTING-001: Initialized Camunda Spring Boot Eventing Engine Plugin.");
    if (property.isTask()) {
      logger.info("EVENTING-003: Task events will be published as Spring Events.");
    } else {
      logger.info("EVENTING-004: Task eventing is disabled via property.");
    }

    if (property.isExecution()) {
      logger.info("EVENTING-005: Execution events will be published as Spring Events.");
    } else {
      logger.info("EVENTING-006: Execution eventing is disabled via property.");
    }
    // register parse listener
    processEngineConfiguration.getCustomPostBPMNParseListeners().add(new PublishDelegateParseListener(this.publisher, property));
  }

  if (property.isHistory()) {
    logger.info("EVENTING-007: History events will be published as Spring events.");
    // register composite DB event handler.
    processEngineConfiguration.getCustomHistoryEventHandlers()
        .add(new PublishHistoryEventHandler(this.publisher));
  } else {
    logger.info("EVENTING-008: History eventing is disabled via property.");
  }

}
 
Example #13
Source File: DefaultFailedJobConfiguration.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration configuration) {

  if (configuration.getCustomPostBPMNParseListeners() == null) {
    configuration.setCustomPostBPMNParseListeners(new ArrayList<>());
  }

  configuration.getCustomPostBPMNParseListeners().add(new DefaultFailedJobParseListener());
  configuration.setFailedJobCommandFactory(new DefaultFailedJobCommandFactory());
}
 
Example #14
Source File: DefaultDeploymentConfiguration.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration configuration) {
  if (camundaBpmProperties.isAutoDeploymentEnabled()) {
    final Set<Resource> resources = getDeploymentResources();
    configuration.setDeploymentResources(resources.toArray(new Resource[resources.size()]));
    LOG.autoDeployResources(resources);
  }
}
 
Example #15
Source File: DefaultHistoryLevelAutoHandlingConfiguration.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration configuration) {
  final String determineHistoryLevel = historyLevelDeterminator.determineHistoryLevel();
  if (!StringUtils.isEmpty(determineHistoryLevel)) {
    configuration.setHistory(determineHistoryLevel);
  }
}
 
Example #16
Source File: DefaultAuthorizationConfiguration.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(final SpringProcessEngineConfiguration configuration) {
  final AuthorizationProperty authorization = camundaBpmProperties.getAuthorization();
  configuration.setAuthorizationEnabled(authorization.isEnabled());
  configuration.setAuthorizationEnabledForCustomCode(authorization.isEnabledForCustomCode());
  configuration.setAuthorizationCheckRevokes(authorization.getAuthorizationCheckRevokes());

  configuration.setTenantCheckEnabled(authorization.isTenantCheckEnabled());
}
 
Example #17
Source File: CustomBpmConfig.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration processEngineConfiguration) {
    super.preInit(processEngineConfiguration);

    List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners();
    if (preParseListeners == null) {
        preParseListeners = new ArrayList<BpmnParseListener>();
        processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners);
    }

    log.info("adding LocalBpmnParseListener:{}", processStartAndEndEventInitializer.getClass().getName());

    preParseListeners.add(processStartAndEndEventInitializer);
}
 
Example #18
Source File: DefaultJobConfiguration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void configureJobExecutor(SpringProcessEngineConfiguration configuration) {
  // note: the job executor will be activated in
  // org.camunda.bpm.spring.boot.starter.runlistener.JobExecutorRunListener
  configuration.setJobExecutorActivate(false);
  configuration.setJobExecutorDeploymentAware(camundaBpmProperties.getJobExecution().isDeploymentAware());
  configuration.setJobExecutor(jobExecutor);

}
 
Example #19
Source File: DefaultHistoryConfiguration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration configuration) {
  String historyLevel = camundaBpmProperties.getHistoryLevel();
  if (historyLevel != null) {
    configuration.setHistory(historyLevel);
  }
  if (historyEventHandler != null) {
    logger.debug("registered history event handler: {}", historyEventHandler.getClass());
    configuration.getCustomHistoryEventHandlers().add(historyEventHandler);
  }
}
 
Example #20
Source File: DefaultAuthorizationConfiguration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(final SpringProcessEngineConfiguration configuration) {
  final AuthorizationProperty authorization = camundaBpmProperties.getAuthorization();
  configuration.setAuthorizationEnabled(authorization.isEnabled());
  configuration.setAuthorizationEnabledForCustomCode(authorization.isEnabledForCustomCode());
  configuration.setAuthorizationCheckRevokes(authorization.getAuthorizationCheckRevokes());

  configuration.setTenantCheckEnabled(authorization.isTenantCheckEnabled());
}
 
Example #21
Source File: DefaultDeploymentConfiguration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration configuration) {
  if (camundaBpmProperties.isAutoDeploymentEnabled()) {
    final Set<Resource> resources = getDeploymentResources();
    configuration.setDeploymentResources(resources.toArray(new Resource[resources.size()]));
    LOG.autoDeployResources(resources);
  }
}
 
Example #22
Source File: DefaultHistoryLevelAutoHandlingConfiguration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration configuration) {
  final String determineHistoryLevel = historyLevelDeterminator.determineHistoryLevel();
  if (!StringUtils.isEmpty(determineHistoryLevel)) {
    configuration.setHistory(determineHistoryLevel);
  }
}
 
Example #23
Source File: DefaultFailedJobConfiguration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration configuration) {

  if (configuration.getCustomPostBPMNParseListeners() == null) {
    configuration.setCustomPostBPMNParseListeners(new ArrayList<>());
  }

  configuration.getCustomPostBPMNParseListeners().add(new DefaultFailedJobParseListener());
  configuration.setFailedJobCommandFactory(new DefaultFailedJobCommandFactory());
}
 
Example #24
Source File: DefaultProcessEngineConfiguration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration configuration) {
  setProcessEngineName(configuration);
  setDefaultSerializationFormat(configuration);
  setIdGenerator(configuration);
  setJobExecutorAcquireByPriority(configuration);
  setDefaultNumberOfRetries(configuration);
}
 
Example #25
Source File: DefaultProcessEngineConfiguration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private void setDefaultSerializationFormat(SpringProcessEngineConfiguration configuration) {
  String defaultSerializationFormat = camundaBpmProperties.getDefaultSerializationFormat();
  if (StringUtils.hasText(defaultSerializationFormat)) {
    configuration.setDefaultSerializationFormat(defaultSerializationFormat);
  } else {
    logger.warn("Ignoring invalid defaultSerializationFormat='{}'", defaultSerializationFormat);
  }
}
 
Example #26
Source File: DefaultJpaConfiguration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration configuration) {
  final JpaProperty jpa = camundaBpmProperties.getJpa();

  configuration.setJpaPersistenceUnitName(jpa.getPersistenceUnitName());
  if (jpaEntityManagerFactory != null) {
    configuration.setJpaEntityManagerFactory(jpaEntityManagerFactory);
  }
  configuration.setJpaCloseEntityManager(jpa.isCloseEntityManager());
  configuration.setJpaHandleTransaction(jpa.isHandleTransaction());
}
 
Example #27
Source File: EventPublisherPlugin.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration processEngineConfiguration) {

  if (!property.isTask() && !property.isExecution() && !property.isHistory()) {
    logger.info("EVENTING-002: Camunda Spring Boot Eventing Plugin is found, but disabled via property.");
    return;
  }

  if (property.isTask() || property.isExecution()) {

    logger.info("EVENTING-001: Initialized Camunda Spring Boot Eventing Engine Plugin.");
    if (property.isTask()) {
      logger.info("EVENTING-003: Task events will be published as Spring Events.");
    } else {
      logger.info("EVENTING-004: Task eventing is disabled via property.");
    }

    if (property.isExecution()) {
      logger.info("EVENTING-005: Execution events will be published as Spring Events.");
    } else {
      logger.info("EVENTING-006: Execution eventing is disabled via property.");
    }
    // register parse listener
    processEngineConfiguration.getCustomPostBPMNParseListeners().add(new PublishDelegateParseListener(this.publisher, property));
  }

  if (property.isHistory()) {
    logger.info("EVENTING-007: History events will be published as Spring events.");
    // register composite DB event handler.
    processEngineConfiguration.getCustomHistoryEventHandlers()
        .add(new PublishHistoryEventHandler(this.publisher));
  } else {
    logger.info("EVENTING-008: History eventing is disabled via property.");
  }

}
 
Example #28
Source File: GenericPropertiesConfigurationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
  processEngineConfiguration = new SpringProcessEngineConfiguration();
  genericPropertiesConfiguration = new GenericPropertiesConfiguration();
  camundaBpmProperties = new CamundaBpmProperties();
  genericPropertiesConfiguration.camundaBpmProperties = camundaBpmProperties;
}
 
Example #29
Source File: SpringBootProcessEnginePluginTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void delegate_for_springConfig() throws Exception {
  ProcessEngineConfigurationImpl c = new SpringProcessEngineConfiguration();

  DummySpringPlugin plugin = new DummySpringPlugin();

  plugin.preInit(c);
  plugin.postInit(c);

  assertThat(plugin.preInit).isTrue();
  assertThat(plugin.postInit).isTrue();
}
 
Example #30
Source File: InMemProcessEngineConfiguration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Bean
public SpringProcessEngineConfiguration processEngineConfiguration() {
  SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();

  config.setDataSource(dataSource());
  config.setDatabaseSchemaUpdate("true");

  config.setTransactionManager(transactionManager());

  config.setHistory("audit");
  config.setJobExecutorActivate(false);
  config.setDbMetricsReporterActivate(false);

  return config;
}