Search in sources :

Example 1 with ProcessEnginePluginXml

use of org.camunda.bpm.container.impl.metadata.spi.ProcessEnginePluginXml in project camunda-bpm-platform by camunda.

the class MscManagedProcessEngineController method addProcessEnginePlugins.

protected void addProcessEnginePlugins(JtaProcessEngineConfiguration processEngineConfiguration) {
    // add process engine plugins:
    List<ProcessEnginePluginXml> pluginConfigurations = processEngineMetadata.getPluginConfigurations();
    for (ProcessEnginePluginXml pluginXml : pluginConfigurations) {
        // create plugin instance
        ProcessEnginePlugin plugin = null;
        String pluginClassName = pluginXml.getPluginClass();
        try {
            plugin = (ProcessEnginePlugin) createInstance(pluginClassName);
        } catch (ClassCastException e) {
            throw new ProcessEngineException("Process engine plugin '" + pluginClassName + "' does not implement interface " + ProcessEnginePlugin.class.getName() + "'.");
        }
        // apply configured properties
        Map<String, String> properties = pluginXml.getProperties();
        PropertyHelper.applyProperties(plugin, properties);
        // add to configuration
        processEngineConfiguration.getProcessEnginePlugins().add(plugin);
    }
}
Also used : ProcessEnginePluginXml(org.camunda.bpm.container.impl.metadata.spi.ProcessEnginePluginXml) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessEnginePlugin(org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin)

Example 2 with ProcessEnginePluginXml

use of org.camunda.bpm.container.impl.metadata.spi.ProcessEnginePluginXml in project camunda-bpm-platform by camunda.

the class ManagedProcessEngineMetadata method validate.

/**
 * validates the configuration and throws {@link ProcessEngineException}
 * if the configuration is invalid.
 */
public void validate() {
    StringBuilder validationErrorBuilder = new StringBuilder("Process engine configuration is invalid: \n");
    boolean isValid = true;
    if (datasourceJndiName == null || datasourceJndiName.isEmpty()) {
        isValid = false;
        validationErrorBuilder.append(" property 'datasource' cannot be null \n");
    }
    if (engineName == null || engineName.isEmpty()) {
        isValid = false;
        validationErrorBuilder.append(" property 'engineName' cannot be null \n");
    }
    for (int i = 0; i < pluginConfigurations.size(); i++) {
        ProcessEnginePluginXml pluginConfiguration = pluginConfigurations.get(i);
        if (pluginConfiguration.getPluginClass() == null || pluginConfiguration.getPluginClass().isEmpty()) {
            isValid = false;
            validationErrorBuilder.append(" property 'class' in plugin[" + i + "] cannot be null \n");
        }
    }
    if (!isValid) {
        throw new ProcessEngineException(validationErrorBuilder.toString());
    }
}
Also used : ProcessEnginePluginXml(org.camunda.bpm.container.impl.metadata.spi.ProcessEnginePluginXml) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 3 with ProcessEnginePluginXml

use of org.camunda.bpm.container.impl.metadata.spi.ProcessEnginePluginXml in project camunda-bpm-platform by camunda.

the class DeploymentMetadataParse method parseProcessEngine.

/**
 * parse a <code>&lt;process-engine .../&gt;</code> element and add it to the list of parsed elements
 */
protected void parseProcessEngine(Element element, List<ProcessEngineXml> parsedProcessEngines) {
    ProcessEngineXmlImpl processEngine = new ProcessEngineXmlImpl();
    // set name
    processEngine.setName(element.attribute(NAME));
    // set default
    String defaultValue = element.attribute(DEFAULT);
    if (defaultValue == null || defaultValue.isEmpty()) {
        processEngine.setDefault(false);
    } else {
        processEngine.setDefault(Boolean.parseBoolean(defaultValue));
    }
    Map<String, String> properties = new HashMap<String, String>();
    List<ProcessEnginePluginXml> plugins = new ArrayList<ProcessEnginePluginXml>();
    for (Element childElement : element.elements()) {
        if (CONFIGURATION.equals(childElement.getTagName())) {
            processEngine.setConfigurationClass(childElement.getText());
        } else if (DATASOURCE.equals(childElement.getTagName())) {
            processEngine.setDatasource(childElement.getText());
        } else if (JOB_ACQUISITION.equals(childElement.getTagName())) {
            processEngine.setJobAcquisitionName(childElement.getText());
        } else if (PROPERTIES.equals(childElement.getTagName())) {
            parseProperties(childElement, properties);
        } else if (PLUGINS.equals(childElement.getTagName())) {
            parseProcessEnginePlugins(childElement, plugins);
        }
    }
    // set collected properties
    processEngine.setProperties(properties);
    // set plugins
    processEngine.setPlugins(plugins);
    // add the process engine to the list of parsed engines.
    parsedProcessEngines.add(processEngine);
}
Also used : ProcessEnginePluginXml(org.camunda.bpm.container.impl.metadata.spi.ProcessEnginePluginXml) HashMap(java.util.HashMap) Element(org.camunda.bpm.engine.impl.util.xml.Element) ArrayList(java.util.ArrayList)

Example 4 with ProcessEnginePluginXml

use of org.camunda.bpm.container.impl.metadata.spi.ProcessEnginePluginXml in project camunda-bpm-platform by camunda.

the class JBossSubsystemXMLTest method testInstallSubsystemWithEnginesPropertiesPlugins.

@Test
public void testInstallSubsystemWithEnginesPropertiesPlugins() throws Exception {
    String subsystemXml = FileUtils.readFile(SUBSYSTEM_WITH_ENGINES_PROPERTIES_PLUGINS);
    KernelServices services = createKernelServicesBuilder(null).setSubsystemXml(subsystemXml).build();
    ServiceContainer container = services.getContainer();
    assertNotNull("platform service should be installed", container.getRequiredService(PLATFORM_SERVICE_NAME));
    assertNotNull("process engine service should be bound in JNDI", container.getRequiredService(PROCESS_ENGINE_SERVICE_BINDING_SERVICE_NAME));
    ServiceController<?> defaultEngineService = container.getService(ServiceNames.forManagedProcessEngine("__default"));
    assertNotNull("process engine controller for engine __default is installed ", defaultEngineService);
    ManagedProcessEngineMetadata metadata = ((MscManagedProcessEngineController) defaultEngineService.getService()).getProcessEngineMetadata();
    Map<String, String> configurationProperties = metadata.getConfigurationProperties();
    assertEquals("default", configurationProperties.get("job-name"));
    assertEquals("default", configurationProperties.get("job-acquisition"));
    assertEquals("default", configurationProperties.get("job-acquisition-name"));
    Map<String, String> foxLegacyProperties = metadata.getFoxLegacyProperties();
    assertTrue(foxLegacyProperties.isEmpty());
    assertNotNull("process engine controller for engine __default is installed ", container.getRequiredService(ServiceNames.forManagedProcessEngine("__default")));
    assertNotNull("process engine controller for engine __test is installed ", container.getRequiredService(ServiceNames.forManagedProcessEngine("__test")));
    // check we have parsed the plugin configurations
    metadata = ((MscManagedProcessEngineController) container.getRequiredService(ServiceNames.forManagedProcessEngine("__test")).getService()).getProcessEngineMetadata();
    List<ProcessEnginePluginXml> pluginConfigurations = metadata.getPluginConfigurations();
    ProcessEnginePluginXml processEnginePluginXml = pluginConfigurations.get(0);
    assertEquals("org.camunda.bpm.identity.impl.ldap.plugin.LdapIdentityProviderPlugin", processEnginePluginXml.getPluginClass());
    Map<String, String> processEnginePluginXmlProperties = processEnginePluginXml.getProperties();
    assertEquals("abc", processEnginePluginXmlProperties.get("test"));
    assertEquals("123", processEnginePluginXmlProperties.get("number"));
    assertEquals("true", processEnginePluginXmlProperties.get("bool"));
    processEnginePluginXml = pluginConfigurations.get(1);
    assertEquals("org.camunda.bpm.identity.impl.ldap.plugin.LdapIdentityProviderPlugin", processEnginePluginXml.getPluginClass());
    processEnginePluginXmlProperties = processEnginePluginXml.getProperties();
    assertEquals("cba", processEnginePluginXmlProperties.get("test"));
    assertEquals("321", processEnginePluginXmlProperties.get("number"));
    assertEquals("false", processEnginePluginXmlProperties.get("bool"));
    // test correct subsystem removal
    assertRemoveSubsystemResources(services);
    try {
        ServiceController<?> service = container.getRequiredService(ServiceNames.forManagedProcessEngine("__default"));
        fail("Service '" + service.getName() + "' should have been removed.");
    } catch (Exception expected) {
    // nop
    }
    try {
        ServiceController<?> service = container.getRequiredService(ServiceNames.forManagedProcessEngine("__test"));
        fail("Service '" + service.getName() + "' should have been removed.");
    } catch (Exception expected) {
    // nop
    }
}
Also used : ServiceContainer(org.jboss.msc.service.ServiceContainer) ProcessEnginePluginXml(org.camunda.bpm.container.impl.metadata.spi.ProcessEnginePluginXml) KernelServices(org.jboss.as.subsystem.test.KernelServices) ManagedProcessEngineMetadata(org.camunda.bpm.container.impl.jboss.config.ManagedProcessEngineMetadata) MscManagedProcessEngineController(org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController) XMLStreamException(javax.xml.stream.XMLStreamException) AbstractSubsystemTest(org.jboss.as.subsystem.test.AbstractSubsystemTest) Test(org.junit.Test)

Example 5 with ProcessEnginePluginXml

use of org.camunda.bpm.container.impl.metadata.spi.ProcessEnginePluginXml in project camunda-bpm-platform by camunda.

the class ProcessEngineAdd method getPlugins.

protected List<ProcessEnginePluginXml> getPlugins(ModelNode plugins) {
    List<ProcessEnginePluginXml> pluginConfigurations = new ArrayList<>();
    if (plugins.isDefined()) {
        for (final ModelNode plugin : plugins.asList()) {
            ProcessEnginePluginXml processEnginePluginXml = new ProcessEnginePluginXml() {

                @Override
                public String getPluginClass() {
                    return plugin.get(Element.PLUGIN_CLASS.getLocalName()).asString();
                }

                @Override
                public Map<String, String> getProperties() {
                    return ProcessEngineAdd.this.getProperties(plugin.get(Element.PROPERTIES.getLocalName()));
                }
            };
            pluginConfigurations.add(processEnginePluginXml);
        }
    }
    return pluginConfigurations;
}
Also used : ProcessEnginePluginXml(org.camunda.bpm.container.impl.metadata.spi.ProcessEnginePluginXml) ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

ProcessEnginePluginXml (org.camunda.bpm.container.impl.metadata.spi.ProcessEnginePluginXml)11 BpmPlatformXml (org.camunda.bpm.container.impl.metadata.spi.BpmPlatformXml)4 ProcessEngineXml (org.camunda.bpm.container.impl.metadata.spi.ProcessEngineXml)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 ProcessEnginePlugin (org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin)2 XMLStreamException (javax.xml.stream.XMLStreamException)1 ManagedProcessEngineMetadata (org.camunda.bpm.container.impl.jboss.config.ManagedProcessEngineMetadata)1 MscManagedProcessEngineController (org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController)1 ProcessEngineXmlImpl (org.camunda.bpm.container.impl.metadata.ProcessEngineXmlImpl)1 JobAcquisitionXml (org.camunda.bpm.container.impl.metadata.spi.JobAcquisitionXml)1 JobExecutorXml (org.camunda.bpm.container.impl.metadata.spi.JobExecutorXml)1 StandaloneInMemProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration)1 Element (org.camunda.bpm.engine.impl.util.xml.Element)1 AbstractSubsystemTest (org.jboss.as.subsystem.test.AbstractSubsystemTest)1 KernelServices (org.jboss.as.subsystem.test.KernelServices)1 ModelNode (org.jboss.dmr.ModelNode)1 ServiceContainer (org.jboss.msc.service.ServiceContainer)1 Test (org.junit.Test)1