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);
}
}
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());
}
}
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><process-engine .../></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);
}
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
}
}
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;
}
Aggregations