Search in sources :

Example 1 with ProcessesXml

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

the class ProcessesXmlProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!ProcessApplicationAttachments.isProcessApplication(deploymentUnit)) {
        return;
    }
    final Module module = deploymentUnit.getAttachment(MODULE);
    // read @ProcessApplication annotation of PA-component
    String[] deploymentDescriptors = getDeploymentDescriptors(deploymentUnit);
    // load all processes.xml files
    List<URL> deploymentDescriptorURLs = getDeploymentDescriptorUrls(module, deploymentDescriptors);
    for (URL processesXmlResource : deploymentDescriptorURLs) {
        VirtualFile processesXmlFile = getFile(processesXmlResource);
        // parse processes.xml metadata.
        ProcessesXml processesXml = null;
        if (isEmptyFile(processesXmlResource)) {
            processesXml = ProcessesXml.EMPTY_PROCESSES_XML;
        } else {
            processesXml = parseProcessesXml(processesXmlResource);
        }
        // add the parsed metadata to the attachment list
        ProcessApplicationAttachments.addProcessesXml(deploymentUnit, new ProcessesXmlWrapper(processesXml, processesXmlFile));
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ProcessesXmlWrapper(org.camunda.bpm.container.impl.jboss.util.ProcessesXmlWrapper) ProcessesXml(org.camunda.bpm.application.impl.metadata.spi.ProcessesXml) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) URL(java.net.URL)

Example 2 with ProcessesXml

use of org.camunda.bpm.application.impl.metadata.spi.ProcessesXml 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 3 with ProcessesXml

use of org.camunda.bpm.application.impl.metadata.spi.ProcessesXml 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 4 with ProcessesXml

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

the class ParseProcessesXmlStep method parseProcessesXml.

protected ProcessesXml parseProcessesXml(URL url) {
    final ProcessesXmlParser processesXmlParser = new ProcessesXmlParser();
    ProcessesXml processesXml = processesXmlParser.createParse().sourceUrl(url).execute().getProcessesXml();
    return processesXml;
}
Also used : ProcessesXml(org.camunda.bpm.application.impl.metadata.spi.ProcessesXml) ProcessesXmlParser(org.camunda.bpm.application.impl.metadata.ProcessesXmlParser)

Example 5 with ProcessesXml

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

the class ParseProcessesXmlStep method parseProcessesXmlFiles.

protected Map<URL, ProcessesXml> parseProcessesXmlFiles(final AbstractProcessApplication processApplication) {
    String[] deploymentDescriptors = getDeploymentDescriptorLocations(processApplication);
    List<URL> processesXmlUrls = getProcessesXmlUrls(deploymentDescriptors, processApplication);
    Map<URL, ProcessesXml> parsedFiles = new HashMap<URL, ProcessesXml>();
    // perform parsing
    for (URL url : processesXmlUrls) {
        LOG.foundProcessesXmlFile(url.toString());
        if (isEmptyFile(url)) {
            parsedFiles.put(url, ProcessesXml.EMPTY_PROCESSES_XML);
            LOG.emptyProcessesXml();
        } else {
            parsedFiles.put(url, parseProcessesXml(url));
        }
    }
    if (parsedFiles.isEmpty()) {
        LOG.noProcessesXmlForPa(processApplication.getName());
    }
    return parsedFiles;
}
Also used : ProcessesXml(org.camunda.bpm.application.impl.metadata.spi.ProcessesXml) HashMap(java.util.HashMap) URL(java.net.URL)

Aggregations

ProcessesXml (org.camunda.bpm.application.impl.metadata.spi.ProcessesXml)19 ProcessArchiveXml (org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml)8 URL (java.net.URL)5 AbstractProcessApplication (org.camunda.bpm.application.AbstractProcessApplication)4 ProcessEngineXml (org.camunda.bpm.container.impl.metadata.spi.ProcessEngineXml)4 JmxManagedProcessApplication (org.camunda.bpm.container.impl.jmx.services.JmxManagedProcessApplication)3 PlatformServiceContainer (org.camunda.bpm.container.impl.spi.PlatformServiceContainer)3 ArrayList (java.util.ArrayList)2 ProcessesXmlParser (org.camunda.bpm.application.impl.metadata.ProcessesXmlParser)2 DeployedProcessArchive (org.camunda.bpm.container.impl.deployment.util.DeployedProcessArchive)2 ProcessesXmlWrapper (org.camunda.bpm.container.impl.jboss.util.ProcessesXmlWrapper)2 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)2 Module (org.jboss.modules.Module)2 HashMap (java.util.HashMap)1 ProcessApplicationInfoImpl (org.camunda.bpm.application.impl.ProcessApplicationInfoImpl)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 BpmPlatformPlugins (org.camunda.bpm.container.impl.plugin.BpmPlatformPlugins)1 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)1