org.camunda.bpm.engine.impl.cfg.CompositeProcessEnginePlugin Java Examples

The following examples show how to use org.camunda.bpm.engine.impl.cfg.CompositeProcessEnginePlugin. 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: CamundaReactor.java    From camunda-bpm-reactor with Apache License 2.0 6 votes vote down vote up
/**
 * Gets EventBus from given process engine via plugin.
 *
 * @param processEngine the process engine
 * @return the camunda eventBus
 */
public static CamundaEventBus eventBus(final ProcessEngine processEngine) {
  final ProcessEngineConfigurationImpl configuration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();
  final List<ProcessEnginePlugin> plugins = Optional.ofNullable(configuration.getProcessEnginePlugins()).orElse(Collections.EMPTY_LIST);

  final Function<List<ProcessEnginePlugin>, Optional<CamundaEventBus>> filterReactorPlugin = l -> l.stream()
    .filter(plugin -> plugin instanceof ReactorProcessEnginePlugin)
    .map(ReactorProcessEnginePlugin.class::cast)
    .map(ReactorProcessEnginePlugin::getEventBus)
    .findFirst();

  Optional<CamundaEventBus> reactorProcessEnginePlugin = filterReactorPlugin.apply(plugins);
  if (reactorProcessEnginePlugin.isPresent()) {
    return reactorProcessEnginePlugin.get();
  }

  return plugins.stream()
    .filter(plugin -> plugin instanceof CompositeProcessEnginePlugin)
    .map(CompositeProcessEnginePlugin.class::cast)
    .map(CompositeProcessEnginePlugin::getPlugins)
    .map(filterReactorPlugin)
    .flatMap(o -> o.map(Stream::of).orElseGet(Stream::empty))
    .findFirst()
    .orElseThrow(illegalState("No eventBus found. Make sure the Reactor plugin is configured correctly."));
}
 
Example #2
Source File: CamundaReactorTest.java    From camunda-bpm-reactor with Apache License 2.0 6 votes vote down vote up
@Test
public void get_eventBus_from_engine_composite() {
  final CamundaEventBus eventBus = new CamundaEventBus();
  ReactorProcessEnginePlugin plugin = new ReactorProcessEnginePlugin(eventBus);

  ReactorProcessEngineConfiguration configuration = new ReactorProcessEngineConfiguration(eventBus);
  configuration.getProcessEnginePlugins().clear();

  configuration.getProcessEnginePlugins().add(new CompositeProcessEnginePlugin(plugin));

  ProcessEngine engine = configuration.buildProcessEngine();

  try {
    assertThat(CamundaReactor.eventBus(engine)).isEqualTo(eventBus);

  } finally {
    engine.close();
  }
}
 
Example #3
Source File: CamundaBpmAutoConfigurationIT.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 6 votes vote down vote up
@Test
public void ensureSpinProcessEnginePluginIsCorrectlyLoaded() {
  // given
  List<ProcessEnginePlugin> plugins = processEngineConfiguration.getProcessEnginePlugins();
  List<TypedValueSerializer<?>> serializers = processEngineConfiguration.getVariableSerializers().getSerializers();

  if (plugins.get(0) instanceof CompositeProcessEnginePlugin) {
    plugins = ((CompositeProcessEnginePlugin) plugins.get(0)).getPlugins();
  }

  boolean isJacksonJsonDataFormat = serializers.stream().anyMatch(s ->
      s instanceof SpinObjectValueSerializer
      && s.getSerializationDataformat().equals("application/json"));

  // then
  assertThat(plugins.stream().anyMatch(plugin -> plugin instanceof SpinProcessEnginePlugin)).isTrue();
  assertThat(isJacksonJsonDataFormat).isTrue();
}
 
Example #4
Source File: CamundaBpmAutoConfigurationIT.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void ensureSpinProcessEnginePluginIsCorrectlyLoaded() {
  // given
  List<ProcessEnginePlugin> plugins = processEngineConfiguration.getProcessEnginePlugins();
  List<TypedValueSerializer<?>> serializers = processEngineConfiguration.getVariableSerializers().getSerializers();

  if (plugins.get(0) instanceof CompositeProcessEnginePlugin) {
    plugins = ((CompositeProcessEnginePlugin) plugins.get(0)).getPlugins();
  }

  boolean isJacksonJsonDataFormat = serializers.stream().anyMatch(s ->
      s instanceof SpinObjectValueSerializer
      && s.getSerializationDataformat().equals("application/json"));

  // then
  assertThat(plugins.stream().anyMatch(plugin -> plugin instanceof SpinProcessEnginePlugin)).isTrue();
  assertThat(isJacksonJsonDataFormat).isTrue();
}
 
Example #5
Source File: CustomBpmConfig.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(ProcessEngineConfigurationImpl.class)
public ProcessEngineConfigurationImpl processEngineConfigurationImpl(
        List<ProcessEnginePlugin> processEnginePlugins) {

    log.info("configure process engine configuration impl,class={}",
            CustomSpringProcessEngineConfiguration.class.getName());
    final SpringProcessEngineConfiguration configuration = CamundaSpringBootUtil
            .initCustomFields(new CustomSpringProcessEngineConfiguration());
    configuration.getProcessEnginePlugins().add(new CompositeProcessEnginePlugin(processEnginePlugins));
    return configuration;
}
 
Example #6
Source File: CamundaBpmConfiguration.java    From camunda-bpm-spring-boot-starter 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 #7
Source File: CamundaBpmConfigurationTest.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Test
public void processEngineConfigurationImplTest() {
  CamundaBpmConfiguration camundaBpmConfiguration = new CamundaBpmConfiguration();
  List<ProcessEnginePlugin> processEnginePlugins = createUnordedList();
  ProcessEngineConfigurationImpl processEngineConfigurationImpl = camundaBpmConfiguration.processEngineConfigurationImpl(processEnginePlugins);

  CompositeProcessEnginePlugin compositeProcessEnginePlugin = (CompositeProcessEnginePlugin) processEngineConfigurationImpl.getProcessEnginePlugins().get(0);
  assertThat(compositeProcessEnginePlugin.getPlugins()).isEqualTo(processEnginePlugins);
}
 
Example #8
Source File: CamundaBpmAutoConfigurationIT.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Test
public void ensureConnectProcessEnginePluginIsCorrectlyLoaded() {
  // given
  List<ProcessEnginePlugin> plugins = processEngineConfiguration.getProcessEnginePlugins();

  if (plugins.get(0) instanceof CompositeProcessEnginePlugin) {
    plugins = ((CompositeProcessEnginePlugin) plugins.get(0)).getPlugins();
  }

  // then
  assertThat(plugins.stream().anyMatch(plugin -> plugin instanceof ConnectProcessEnginePlugin)).isTrue();
}
 
Example #9
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 #10
Source File: CamundaBpmConfigurationTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void processEngineConfigurationImplTest() {
  CamundaBpmConfiguration camundaBpmConfiguration = new CamundaBpmConfiguration();
  List<ProcessEnginePlugin> processEnginePlugins = createUnordedList();
  ProcessEngineConfigurationImpl processEngineConfigurationImpl = camundaBpmConfiguration.processEngineConfigurationImpl(processEnginePlugins);

  CompositeProcessEnginePlugin compositeProcessEnginePlugin = (CompositeProcessEnginePlugin) processEngineConfigurationImpl.getProcessEnginePlugins().get(0);
  assertThat(compositeProcessEnginePlugin.getPlugins()).isEqualTo(processEnginePlugins);
}
 
Example #11
Source File: CamundaBpmAutoConfigurationIT.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void ensureConnectProcessEnginePluginIsCorrectlyLoaded() {
  // given
  List<ProcessEnginePlugin> plugins = processEngineConfiguration.getProcessEnginePlugins();

  if (plugins.get(0) instanceof CompositeProcessEnginePlugin) {
    plugins = ((CompositeProcessEnginePlugin) plugins.get(0)).getPlugins();
  }

  // then
  assertThat(plugins.stream().anyMatch(plugin -> plugin instanceof ConnectProcessEnginePlugin)).isTrue();
}
 
Example #12
Source File: CamundaBpmRunConfiguration.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Bean
public ProcessEngineConfigurationImpl processEngineConfigurationImpl(List<ProcessEnginePlugin> processEnginePlugins) {
  final SpringProcessEngineConfiguration configuration = new CamundaBpmRunProcessEngineConfiguration();
  configuration.getProcessEnginePlugins().add(new CompositeProcessEnginePlugin(processEnginePlugins));
  return configuration;
}