Search in sources :

Example 1 with ProcessArchiveXml

use of org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml in project camunda-bpm-platform by camunda.

the class ProcessApplicationDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!ProcessApplicationAttachments.isProcessApplication(deploymentUnit)) {
        return;
    }
    final ComponentDescription paComponent = getProcessApplicationComponent(deploymentUnit);
    final ServiceName paViewServiceName = getProcessApplicationViewServiceName(paComponent);
    Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    final String moduleName = module.getIdentifier().toString();
    final ServiceName paStartServiceName = ServiceNames.forProcessApplicationStartService(moduleName);
    final ServiceName paStopServiceName = ServiceNames.forProcessApplicationStopService(moduleName);
    final ServiceName noViewStartService = ServiceNames.forNoViewProcessApplicationStartService(moduleName);
    List<ServiceName> deploymentServiceNames = new ArrayList<ServiceName>();
    ProcessApplicationStopService paStopService = new ProcessApplicationStopService();
    ServiceBuilder<ProcessApplicationStopService> stopServiceBuilder = phaseContext.getServiceTarget().addService(paStopServiceName, paStopService).addDependency(phaseContext.getPhaseServiceName()).addDependency(ServiceNames.forBpmPlatformPlugins(), BpmPlatformPlugins.class, paStopService.getPlatformPluginsInjector()).setInitialMode(Mode.ACTIVE);
    if (paViewServiceName != null) {
        stopServiceBuilder.addDependency(paViewServiceName, ComponentView.class, paStopService.getPaComponentViewInjector());
    } else {
        stopServiceBuilder.addDependency(noViewStartService, ProcessApplicationInterface.class, paStopService.getNoViewProcessApplication());
    }
    stopServiceBuilder.install();
    // deploy all process archives
    List<ProcessesXmlWrapper> processesXmlWrappers = ProcessApplicationAttachments.getProcessesXmls(deploymentUnit);
    for (ProcessesXmlWrapper processesXmlWrapper : processesXmlWrappers) {
        ProcessesXml processesXml = processesXmlWrapper.getProcessesXml();
        for (ProcessArchiveXml processArchive : processesXml.getProcessArchives()) {
            ServiceName processEngineServiceName = getProcessEngineServiceName(processArchive);
            Map<String, byte[]> deploymentResources = getDeploymentResources(processArchive, deploymentUnit, processesXmlWrapper.getProcessesXmlFile());
            // add the deployment service for each process archive we deploy.
            ProcessApplicationDeploymentService deploymentService = new ProcessApplicationDeploymentService(deploymentResources, processArchive, module);
            String processArachiveName = processArchive.getName();
            if (processArachiveName == null) {
                // use random name for deployment service if name is null (we cannot ask the process application yet since the component might not be up.
                processArachiveName = UUID.randomUUID().toString();
            }
            ServiceName deploymentServiceName = ServiceNames.forProcessApplicationDeploymentService(deploymentUnit.getName(), processArachiveName);
            ServiceBuilder<ProcessApplicationDeploymentService> serviceBuilder = phaseContext.getServiceTarget().addService(deploymentServiceName, deploymentService).addDependency(phaseContext.getPhaseServiceName()).addDependency(paStopServiceName).addDependency(processEngineServiceName, ProcessEngine.class, deploymentService.getProcessEngineInjector()).setInitialMode(Mode.ACTIVE);
            if (paViewServiceName != null) {
                // add a dependency on the component start service to make sure we are started after the pa-component (Singleton EJB) has started
                serviceBuilder.addDependency(paComponent.getStartServiceName());
                serviceBuilder.addDependency(paViewServiceName, ComponentView.class, deploymentService.getPaComponentViewInjector());
            } else {
                serviceBuilder.addDependency(noViewStartService, ProcessApplicationInterface.class, deploymentService.getNoViewProcessApplication());
            }
            JBossCompatibilityExtension.addServerExecutorDependency(serviceBuilder, deploymentService.getExecutorInjector(), false);
            serviceBuilder.install();
            deploymentServiceNames.add(deploymentServiceName);
        }
    }
    AnnotationInstance postDeploy = ProcessApplicationAttachments.getPostDeployDescription(deploymentUnit);
    AnnotationInstance preUndeploy = ProcessApplicationAttachments.getPreUndeployDescription(deploymentUnit);
    // register the managed process application start service
    ProcessApplicationStartService paStartService = new ProcessApplicationStartService(deploymentServiceNames, postDeploy, preUndeploy, module);
    ServiceBuilder<ProcessApplicationStartService> serviceBuilder = phaseContext.getServiceTarget().addService(paStartServiceName, paStartService).addDependency(phaseContext.getPhaseServiceName()).addDependency(ServiceNames.forDefaultProcessEngine(), ProcessEngine.class, paStartService.getDefaultProcessEngineInjector()).addDependency(ServiceNames.forBpmPlatformPlugins(), BpmPlatformPlugins.class, paStartService.getPlatformPluginsInjector()).addDependencies(deploymentServiceNames).setInitialMode(Mode.ACTIVE);
    if (paViewServiceName != null) {
        serviceBuilder.addDependency(paViewServiceName, ComponentView.class, paStartService.getPaComponentViewInjector());
    } else {
        serviceBuilder.addDependency(noViewStartService, ProcessApplicationInterface.class, paStartService.getNoViewProcessApplication());
    }
    serviceBuilder.install();
}
Also used : ProcessesXmlWrapper(org.camunda.bpm.container.impl.jboss.util.ProcessesXmlWrapper) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) ProcessApplicationStartService(org.camunda.bpm.container.impl.jboss.service.ProcessApplicationStartService) ProcessArchiveXml(org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml) ArrayList(java.util.ArrayList) ProcessApplicationDeploymentService(org.camunda.bpm.container.impl.jboss.service.ProcessApplicationDeploymentService) BpmPlatformPlugins(org.camunda.bpm.container.impl.plugin.BpmPlatformPlugins) ServiceName(org.jboss.msc.service.ServiceName) ProcessesXml(org.camunda.bpm.application.impl.metadata.spi.ProcessesXml) ProcessApplicationStopService(org.camunda.bpm.container.impl.jboss.service.ProcessApplicationStopService) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 2 with ProcessArchiveXml

use of org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml in project camunda-bpm-platform by camunda.

the class UndeployProcessArchivesStep method performOperationStep.

public void performOperationStep(DeploymentOperation operationContext) {
    final PlatformServiceContainer serviceContainer = operationContext.getServiceContainer();
    final AbstractProcessApplication processApplication = operationContext.getAttachment(Attachments.PROCESS_APPLICATION);
    final JmxManagedProcessApplication deployedProcessApplication = serviceContainer.getService(ServiceTypes.PROCESS_APPLICATION, processApplication.getName());
    ensureNotNull("Cannot find process application with name " + processApplication.getName(), "deployedProcessApplication", deployedProcessApplication);
    Map<String, DeployedProcessArchive> deploymentMap = deployedProcessApplication.getProcessArchiveDeploymentMap();
    if (deploymentMap != null) {
        List<ProcessesXml> processesXmls = deployedProcessApplication.getProcessesXmls();
        for (ProcessesXml processesXml : processesXmls) {
            for (ProcessArchiveXml parsedProcessArchive : processesXml.getProcessArchives()) {
                DeployedProcessArchive deployedProcessArchive = deploymentMap.get(parsedProcessArchive.getName());
                if (deployedProcessArchive != null) {
                    operationContext.addStep(new UndeployProcessArchiveStep(deployedProcessApplication, parsedProcessArchive, deployedProcessArchive.getProcessEngineName()));
                }
            }
        }
    }
}
Also used : AbstractProcessApplication(org.camunda.bpm.application.AbstractProcessApplication) DeployedProcessArchive(org.camunda.bpm.container.impl.deployment.util.DeployedProcessArchive) ProcessesXml(org.camunda.bpm.application.impl.metadata.spi.ProcessesXml) PlatformServiceContainer(org.camunda.bpm.container.impl.spi.PlatformServiceContainer) ProcessArchiveXml(org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml) JmxManagedProcessApplication(org.camunda.bpm.container.impl.jmx.services.JmxManagedProcessApplication)

Example 3 with ProcessArchiveXml

use of org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml in project camunda-bpm-platform by camunda.

the class EmptyProcessesXmlTest method testDefaultValues.

public void testDefaultValues() {
    ProcessesXml emptyProcessesXml = ProcessesXml.EMPTY_PROCESSES_XML;
    assertNotNull(emptyProcessesXml);
    assertNotNull(emptyProcessesXml.getProcessEngines());
    assertEquals(0, emptyProcessesXml.getProcessEngines().size());
    assertNotNull(emptyProcessesXml.getProcessArchives());
    assertEquals(1, emptyProcessesXml.getProcessArchives().size());
    ProcessArchiveXml processArchiveXml = emptyProcessesXml.getProcessArchives().get(0);
    assertNull(processArchiveXml.getName());
    assertNull(processArchiveXml.getProcessEngineName());
    assertNotNull(processArchiveXml.getProcessResourceNames());
    assertEquals(0, processArchiveXml.getProcessResourceNames().size());
    Map<String, String> properties = processArchiveXml.getProperties();
    assertNotNull(properties);
    assertEquals(4, properties.size());
    String isDeleteUponUndeploy = properties.get(ProcessArchiveXml.PROP_IS_DELETE_UPON_UNDEPLOY);
    assertNotNull(isDeleteUponUndeploy);
    assertEquals(Boolean.FALSE.toString(), isDeleteUponUndeploy);
    String isScanForProcessDefinitions = properties.get(ProcessArchiveXml.PROP_IS_SCAN_FOR_PROCESS_DEFINITIONS);
    assertNotNull(isScanForProcessDefinitions);
    assertEquals(Boolean.TRUE.toString(), isScanForProcessDefinitions);
    String isDeployChangedOnly = properties.get(ProcessArchiveXml.PROP_IS_DEPLOY_CHANGED_ONLY);
    assertNotNull(isDeployChangedOnly);
    assertEquals(Boolean.FALSE.toString(), isDeployChangedOnly);
    String resumePreviousBy = properties.get(ProcessArchiveXml.PROP_RESUME_PREVIOUS_BY);
    assertThat(resumePreviousBy, is(notNullValue()));
    assertThat(resumePreviousBy, is(ResumePreviousBy.RESUME_BY_PROCESS_DEFINITION_KEY));
}
Also used : ProcessesXml(org.camunda.bpm.application.impl.metadata.spi.ProcessesXml) ProcessArchiveXml(org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml)

Example 4 with ProcessArchiveXml

use of org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml in project camunda-bpm-platform by camunda.

the class ProcessesXmlParserTest method testParseProcessesXmlOneArchive.

public void testParseProcessesXmlOneArchive() {
    ProcessesXml processesXml = parser.createParse().sourceUrl(getStreamUrl("process_xml_one_archive.xml")).execute().getProcessesXml();
    assertNotNull(processesXml);
    assertEquals(0, processesXml.getProcessEngines().size());
    assertEquals(1, processesXml.getProcessArchives().size());
    ProcessArchiveXml archiveXml1 = processesXml.getProcessArchives().get(0);
    assertEquals("pa1", archiveXml1.getName());
    assertEquals("default", archiveXml1.getProcessEngineName());
    List<String> resourceNames = archiveXml1.getProcessResourceNames();
    assertEquals(2, resourceNames.size());
    assertEquals("process1.bpmn", resourceNames.get(0));
    assertEquals("process2.bpmn", resourceNames.get(1));
    Map<String, String> properties1 = archiveXml1.getProperties();
    assertNotNull(properties1);
    assertEquals(2, properties1.size());
    assertEquals("value1", properties1.get("prop1"));
    assertEquals("value2", properties1.get("prop2"));
}
Also used : ProcessesXml(org.camunda.bpm.application.impl.metadata.spi.ProcessesXml) ProcessArchiveXml(org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml)

Example 5 with ProcessArchiveXml

use of org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml in project camunda-bpm-platform by camunda.

the class ProcessesXmlParse method parseRootElement.

/**
 * we know this is a <code>&lt;process-application ... /&gt;</code> structure.
 */
@Override
protected void parseRootElement() {
    List<ProcessEngineXml> processEngines = new ArrayList<ProcessEngineXml>();
    List<ProcessArchiveXml> processArchives = new ArrayList<ProcessArchiveXml>();
    for (Element element : rootElement.elements()) {
        if (PROCESS_ENGINE.equals(element.getTagName())) {
            parseProcessEngine(element, processEngines);
        } else if (PROCESS_ARCHIVE.equals(element.getTagName())) {
            parseProcessArchive(element, processArchives);
        }
    }
    processesXml = new ProcessesXmlImpl(processEngines, processArchives);
}
Also used : ProcessEngineXml(org.camunda.bpm.container.impl.metadata.spi.ProcessEngineXml) ProcessArchiveXml(org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml) Element(org.camunda.bpm.engine.impl.util.xml.Element) ArrayList(java.util.ArrayList)

Aggregations

ProcessArchiveXml (org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml)9 ProcessesXml (org.camunda.bpm.application.impl.metadata.spi.ProcessesXml)8 ArrayList (java.util.ArrayList)2 ProcessEngineXml (org.camunda.bpm.container.impl.metadata.spi.ProcessEngineXml)2 AbstractProcessApplication (org.camunda.bpm.application.AbstractProcessApplication)1 DeployedProcessArchive (org.camunda.bpm.container.impl.deployment.util.DeployedProcessArchive)1 ProcessApplicationDeploymentService (org.camunda.bpm.container.impl.jboss.service.ProcessApplicationDeploymentService)1 ProcessApplicationStartService (org.camunda.bpm.container.impl.jboss.service.ProcessApplicationStartService)1 ProcessApplicationStopService (org.camunda.bpm.container.impl.jboss.service.ProcessApplicationStopService)1 ProcessesXmlWrapper (org.camunda.bpm.container.impl.jboss.util.ProcessesXmlWrapper)1 JmxManagedProcessApplication (org.camunda.bpm.container.impl.jmx.services.JmxManagedProcessApplication)1 BpmPlatformPlugins (org.camunda.bpm.container.impl.plugin.BpmPlatformPlugins)1 PlatformServiceContainer (org.camunda.bpm.container.impl.spi.PlatformServiceContainer)1 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)1 Element (org.camunda.bpm.engine.impl.util.xml.Element)1 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 AnnotationInstance (org.jboss.jandex.AnnotationInstance)1 Module (org.jboss.modules.Module)1 ServiceName (org.jboss.msc.service.ServiceName)1