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

The following examples show how to use org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin. 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: AbstractElasticSearchTest.java    From camunda-bpm-elasticsearch with Apache License 2.0 6 votes vote down vote up
@Before
public void initialize() {
  ElasticSearchHistoryPluginConfiguration historyPluginConfiguration = ElasticSearchHistoryPluginConfiguration.readConfigurationFromClasspath();
  ElasticSearchHelper.checkIndex(client, historyPluginConfiguration.getIndex());
  ElasticSearchHelper.checkTypeAndMapping(client, historyPluginConfiguration.getIndex(), historyPluginConfiguration.getType());

  List<ProcessEnginePlugin> processEnginePlugins = ((ProcessEngineImpl) processEngineRule.getProcessEngine())
      .getProcessEngineConfiguration()
      .getProcessEnginePlugins();
  for (ProcessEnginePlugin processEnginePlugin : processEnginePlugins) {
    if (processEnginePlugin instanceof ElasticSearchHistoryPlugin) {
      ElasticSearchHistoryPlugin plugin = (ElasticSearchHistoryPlugin) processEnginePlugin;
      plugin.setElasticSearchClient(client);
    }
  }
}
 
Example #2
Source File: PaSpinSupportTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void spinPluginShouldBeRegistered() {

  List<ProcessEnginePlugin> processEnginePlugins = processEngineConfiguration.getProcessEnginePlugins();

  boolean spinPluginFound = false;

  for (ProcessEnginePlugin plugin : processEnginePlugins) {
    if (plugin.getClass().getName().contains("Spin")) {
      spinPluginFound = true;
      break;
    }
  }

  Assert.assertTrue(spinPluginFound);
}
 
Example #3
Source File: StartProcessEngineStep.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * <p>Instantiates and applies all {@link ProcessEnginePlugin}s defined in the processEngineXml
 */
protected void configurePlugins(ProcessEngineConfigurationImpl configuration, ProcessEngineXml processEngineXml, ClassLoader classLoader) {

  for (ProcessEnginePluginXml pluginXml : processEngineXml.getPlugins()) {
    // create plugin instance
    Class<? extends ProcessEnginePlugin> pluginClass = loadClass(pluginXml.getPluginClass(), classLoader, ProcessEnginePlugin.class);
    ProcessEnginePlugin plugin = createInstance(pluginClass);

    // apply configured properties
    Map<String, String> properties = pluginXml.getProperties();
    PropertyHelper.applyProperties(plugin, properties);

    // add to configuration
    configuration.getProcessEnginePlugins().add(plugin);
  }

}
 
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: ElasticSearchClientProvider.java    From camunda-bpm-elasticsearch with Apache License 2.0 6 votes vote down vote up
protected static void createClient(ProcessEngine processEngine) {
  List<ProcessEnginePlugin> processEnginePlugins = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration()
    .getProcessEnginePlugins();

  // check whether process enigne has elastic search plugin configured
  for (ProcessEnginePlugin processEnginePlugin : processEnginePlugins) {
    if (processEnginePlugin instanceof ElasticSearchHistoryPlugin) {
      ElasticSearchHistoryPlugin historyPlugin = (ElasticSearchHistoryPlugin) processEnginePlugin;
      cachedClient = historyPlugin.getElasticSearchClient();
      break;
    }
  }

  if(cachedClient == null) {
    // create new client from classpath configuration
    ElasticSearchHistoryPluginConfiguration elasticSearchPluginConfiguration = ElasticSearchHistoryPluginConfiguration.readConfigurationFromClasspath();
    cachedClient = new ElasticSearchClient(elasticSearchPluginConfiguration);
  }
}
 
Example #6
Source File: StandaloneDebugWebsocketBootstrap.java    From camunda-bpm-workbench with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {

    // start process engine
    StandaloneInMemProcessEngineConfiguration processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration();
    processEngineConfiguration.setProcessEngineName(ProcessEngines.NAME_DEFAULT);

    // add plugins
    List<ProcessEnginePlugin> processEnginePlugins = processEngineConfiguration.getProcessEnginePlugins();
    processEnginePlugins.add(new DebuggerPlugin());
    processEnginePlugins.add(new SpinProcessEnginePlugin());
    processEnginePlugins.add(new ConnectProcessEnginePlugin());

    processEngineConfiguration.buildProcessEngine();

    DebugSessionFactory.getInstance().setSuspend(false);

    // start debug server
    DebugWebsocket debugWebsocket = null;
    try {

      // configure & start the server
      debugWebsocket = new DebugWebsocketConfiguration()
        .port(9090)
        .startServer();

      // block
      debugWebsocket.waitForShutdown();

    } finally {
      if(debugWebsocket != null) {
        debugWebsocket.shutdown();
      }
    }

  }
 
Example #7
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 #8
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 #9
Source File: StandaloneInMemoryTestConfiguration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public StandaloneInMemoryTestConfiguration(List<ProcessEnginePlugin> plugins) {
  jobExecutorActivate = false;
  expressionManager = new MockExpressionManager();
  databaseSchemaUpdate = DB_SCHEMA_UPDATE_DROP_CREATE;
  isDbMetricsReporterActivate = false;
  historyLevel = HistoryLevel.HISTORY_LEVEL_FULL;

  getProcessEnginePlugins().addAll(plugins);
}
 
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: TestApplication.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Bean(name = "spinProcessEnginePlugin")
public ProcessEnginePlugin spinProcessEnginePlugin() {
  return new SpinProcessEnginePlugin() {

    // When testing the NoJpaAutoConfigurationIT test, ensure that no Custom DataFormat
    // Serializers are loaded, otherwise the test's assumption will fail
    @Override
    public void postInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
      registerFunctionMapper(processEngineConfiguration);
      registerScriptResolver(processEngineConfiguration);
      registerValueTypes(processEngineConfiguration);
      registerFallbackSerializer(processEngineConfiguration);
    }
  };
}
 
Example #13
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 #14
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 #15
Source File: AbstractKeycloakIdentityProviderTest.java    From camunda-bpm-identity-keycloak with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for configuring the KeycloakIdentityProviderPlugin with the test setup configuration.
 * @param config the process engine configuration
 * @return the configured KeycloakIdentityProviderPlugin
 */
protected static KeycloakIdentityProviderPlugin configureKeycloakIdentityProviderPlugin(ProcessEngineConfigurationImpl config) {
	for (ProcessEnginePlugin p : config.getProcessEnginePlugins()) {
		if (p instanceof KeycloakIdentityProviderPlugin) {
			KeycloakIdentityProviderPlugin kcp = (KeycloakIdentityProviderPlugin) p;
			kcp.setKeycloakAdminUrl(kcp.getKeycloakAdminUrl().replace("https://localhost:9001/auth", KEYCLOAK_URL));
			kcp.setKeycloakIssuerUrl(kcp.getKeycloakIssuerUrl().replace("https://localhost:9001/auth", KEYCLOAK_URL));
			kcp.setClientSecret(CLIENT_SECRET);
			return kcp;
		}
	}
	throw new IllegalStateException("KeycloakIdentityProviderPlugin not found in process engine plugins.");
}
 
Example #16
Source File: StandaloneInMemoryTestConfiguration.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
public StandaloneInMemoryTestConfiguration(List<ProcessEnginePlugin> plugins) {
  jobExecutorActivate = false;
  expressionManager = new MockExpressionManager();
  databaseSchemaUpdate = DB_SCHEMA_UPDATE_DROP_CREATE;
  isDbMetricsReporterActivate = false;
  historyLevel = HistoryLevel.HISTORY_LEVEL_FULL;

  getProcessEnginePlugins().addAll(plugins);
}
 
Example #17
Source File: TestApplication.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Bean(name = "spinProcessEnginePlugin")
public ProcessEnginePlugin spinProcessEnginePlugin() {
  return new SpinProcessEnginePlugin() {

    // When testing the NoJpaAutoConfigurationIT test, ensure that no Custom DataFormat
    // Serializers are loaded, otherwise the test's assumption will fail
    @Override
    public void postInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
      registerFunctionMapper(processEngineConfiguration);
      registerScriptResolver(processEngineConfiguration);
      registerValueTypes(processEngineConfiguration);
      registerFallbackSerializer(processEngineConfiguration);
    }
  };
}
 
Example #18
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 #19
Source File: PerfTestProcessEngine.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected static ProcessEngine createProcessEngine(javax.sql.DataSource datasource, Properties properties) {

    ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneProcessEngineConfiguration();
    processEngineConfiguration.setDataSource(datasource);
    processEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);

    processEngineConfiguration.setHistory(properties.getProperty("historyLevel"));

    processEngineConfiguration.setJdbcBatchProcessing(Boolean.valueOf(properties.getProperty("jdbcBatchProcessing")));

    // load plugins
    String processEnginePlugins = properties.getProperty("processEnginePlugins", "");
    for (String pluginName : processEnginePlugins.split(",")) {
      if(pluginName.length() > 1) {
        Object pluginInstance = ReflectUtil.instantiate(pluginName);
        if(!(pluginInstance instanceof ProcessEnginePlugin)) {
          throw new PerfTestException("Plugin "+pluginName +" is not an instance of ProcessEnginePlugin");

        } else {
          List<ProcessEnginePlugin> plugins = processEngineConfiguration.getProcessEnginePlugins();
          if(plugins == null) {
            plugins = new ArrayList<ProcessEnginePlugin>();
            processEngineConfiguration.setProcessEnginePlugins(plugins);
          }
          plugins.add((ProcessEnginePlugin) pluginInstance);

        }
      }
    }

    return processEngineConfiguration.buildProcessEngine();
  }
 
Example #20
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 #21
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 #22
Source File: CamundaBpmPluginConfiguration.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "connectProcessEnginePlugin")
public static ProcessEnginePlugin connectProcessEnginePlugin() {
  return new ConnectProcessEnginePlugin();
}
 
Example #23
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;
}
 
Example #24
Source File: StandaloneInMemoryTestConfiguration.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public StandaloneInMemoryTestConfiguration(ProcessEnginePlugin... plugins) {
  this(Optional.ofNullable(plugins)
    .map(Arrays::asList)
    .orElse(Collections.EMPTY_LIST)
  );
}
 
Example #25
Source File: CamundaBpmConfigurationTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
private List<ProcessEnginePlugin> createUnordedList() {
  List<ProcessEnginePlugin> list = new ArrayList<ProcessEnginePlugin>();
  list.add(mock(ProcessEnginePlugin.class));
  list.add(mock(ProcessEnginePlugin.class));
  return list;
}
 
Example #26
Source File: AdditionalCammundaBpmConfigurations.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Bean
public ProcessEnginePlugin afterStandardConfiguration() {
  return new AfterStandardConfiguration();
}
 
Example #27
Source File: AdditionalCammundaBpmConfigurations.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Bean
public ProcessEnginePlugin beforeStandardConfiguration() {
  return new BeforeStandardConfiguration();
}
 
Example #28
Source File: AdditionalCammundaBpmConfigurations.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
@Bean
public ProcessEnginePlugin beforeStandardConfiguration() {
  return new BeforeStandardConfiguration();
}
 
Example #29
Source File: CamundaBpmPluginConfiguration.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "spinProcessEnginePlugin")
public static ProcessEnginePlugin spinProcessEnginePlugin() {
  return new SpringBootSpinProcessEnginePlugin();
}
 
Example #30
Source File: CamundaBpmPluginConfiguration.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "spinProcessEnginePlugin")
public static ProcessEnginePlugin spinProcessEnginePlugin() {
  return new SpringBootSpinProcessEnginePlugin();
}