Search in sources :

Example 1 with DeployedProcessArchive

use of org.camunda.bpm.container.impl.deployment.util.DeployedProcessArchive in project camunda-bpm-platform by camunda.

the class StartProcessApplicationServiceStep method createProcessApplicationInfo.

protected ProcessApplicationInfoImpl createProcessApplicationInfo(final AbstractProcessApplication processApplication, final Map<String, DeployedProcessArchive> processArchiveDeploymentMap) {
    // populate process application info
    ProcessApplicationInfoImpl processApplicationInfo = new ProcessApplicationInfoImpl();
    processApplicationInfo.setName(processApplication.getName());
    processApplicationInfo.setProperties(processApplication.getProperties());
    // create deployment infos
    List<ProcessApplicationDeploymentInfo> deploymentInfoList = new ArrayList<ProcessApplicationDeploymentInfo>();
    if (processArchiveDeploymentMap != null) {
        for (Entry<String, DeployedProcessArchive> deployment : processArchiveDeploymentMap.entrySet()) {
            final DeployedProcessArchive deployedProcessArchive = deployment.getValue();
            for (String deploymentId : deployedProcessArchive.getAllDeploymentIds()) {
                ProcessApplicationDeploymentInfoImpl deploymentInfo = new ProcessApplicationDeploymentInfoImpl();
                deploymentInfo.setDeploymentId(deploymentId);
                deploymentInfo.setProcessEngineName(deployedProcessArchive.getProcessEngineName());
                deploymentInfoList.add(deploymentInfo);
            }
        }
    }
    processApplicationInfo.setDeploymentInfo(deploymentInfoList);
    return processApplicationInfo;
}
Also used : ProcessApplicationDeploymentInfoImpl(org.camunda.bpm.application.impl.ProcessApplicationDeploymentInfoImpl) DeployedProcessArchive(org.camunda.bpm.container.impl.deployment.util.DeployedProcessArchive) ProcessApplicationDeploymentInfo(org.camunda.bpm.application.ProcessApplicationDeploymentInfo) ProcessApplicationInfoImpl(org.camunda.bpm.application.impl.ProcessApplicationInfoImpl) ArrayList(java.util.ArrayList)

Example 2 with DeployedProcessArchive

use of org.camunda.bpm.container.impl.deployment.util.DeployedProcessArchive 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 DeployedProcessArchive

use of org.camunda.bpm.container.impl.deployment.util.DeployedProcessArchive in project camunda-bpm-platform by camunda.

the class DeployProcessArchiveStep method performOperationStep.

@Override
public void performOperationStep(DeploymentOperation operationContext) {
    final PlatformServiceContainer serviceContainer = operationContext.getServiceContainer();
    final AbstractProcessApplication processApplication = operationContext.getAttachment(Attachments.PROCESS_APPLICATION);
    final ClassLoader processApplicationClassloader = processApplication.getProcessApplicationClassloader();
    ProcessEngine processEngine = getProcessEngine(serviceContainer);
    // start building deployment map
    Map<String, byte[]> deploymentMap = new HashMap<String, byte[]>();
    // add all processes listed in the processes.xml
    List<String> listedProcessResources = processArchive.getProcessResourceNames();
    for (String processResource : listedProcessResources) {
        InputStream resourceAsStream = null;
        try {
            resourceAsStream = processApplicationClassloader.getResourceAsStream(processResource);
            byte[] bytes = IoUtil.readInputStream(resourceAsStream, processResource);
            deploymentMap.put(processResource, bytes);
        } finally {
            IoUtil.closeSilently(resourceAsStream);
        }
    }
    // scan for additional process definitions if not turned off
    if (PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_SCAN_FOR_PROCESS_DEFINITIONS, true)) {
        String paResourceRoot = processArchive.getProperties().get(ProcessArchiveXml.PROP_RESOURCE_ROOT_PATH);
        String[] additionalResourceSuffixes = StringUtil.split(processArchive.getProperties().get(ProcessArchiveXml.PROP_ADDITIONAL_RESOURCE_SUFFIXES), ProcessArchiveXml.PROP_ADDITIONAL_RESOURCE_SUFFIXES_SEPARATOR);
        deploymentMap.putAll(findResources(processApplicationClassloader, paResourceRoot, additionalResourceSuffixes));
    }
    // perform process engine deployment
    RepositoryService repositoryService = processEngine.getRepositoryService();
    ProcessApplicationDeploymentBuilder deploymentBuilder = repositoryService.createDeployment(processApplication.getReference());
    // set the name for the deployment
    String deploymentName = processArchive.getName();
    if (deploymentName == null || deploymentName.isEmpty()) {
        deploymentName = processApplication.getName();
    }
    deploymentBuilder.name(deploymentName);
    // set the tenant id for the deployment
    String tenantId = processArchive.getTenantId();
    if (tenantId != null && !tenantId.isEmpty()) {
        deploymentBuilder.tenantId(tenantId);
    }
    // enable duplicate filtering
    deploymentBuilder.enableDuplicateFiltering(PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_DEPLOY_CHANGED_ONLY, false));
    if (PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_RESUME_PREVIOUS_VERSIONS, true)) {
        enableResumingOfPreviousVersions(deploymentBuilder);
    }
    // add all resources obtained through the processes.xml and through scanning
    for (Entry<String, byte[]> deploymentResource : deploymentMap.entrySet()) {
        deploymentBuilder.addInputStream(deploymentResource.getKey(), new ByteArrayInputStream(deploymentResource.getValue()));
    }
    // allow the process application to add additional resources to the deployment
    processApplication.createDeployment(processArchive.getName(), deploymentBuilder);
    Collection<String> deploymentResourceNames = deploymentBuilder.getResourceNames();
    if (!deploymentResourceNames.isEmpty()) {
        LOG.deploymentSummary(deploymentResourceNames, deploymentName);
        // perform the process engine deployment
        deployment = deploymentBuilder.deploy();
        // add attachment
        Map<String, DeployedProcessArchive> processArchiveDeploymentMap = operationContext.getAttachment(Attachments.PROCESS_ARCHIVE_DEPLOYMENT_MAP);
        if (processArchiveDeploymentMap == null) {
            processArchiveDeploymentMap = new HashMap<String, DeployedProcessArchive>();
            operationContext.addAttachment(Attachments.PROCESS_ARCHIVE_DEPLOYMENT_MAP, processArchiveDeploymentMap);
        }
        processArchiveDeploymentMap.put(processArchive.getName(), new DeployedProcessArchive(deployment));
    } else {
        LOG.notCreatingPaDeployment(processApplication.getName());
    }
}
Also used : DeployedProcessArchive(org.camunda.bpm.container.impl.deployment.util.DeployedProcessArchive) HashMap(java.util.HashMap) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ProcessApplicationDeploymentBuilder(org.camunda.bpm.engine.repository.ProcessApplicationDeploymentBuilder) AbstractProcessApplication(org.camunda.bpm.application.AbstractProcessApplication) ByteArrayInputStream(java.io.ByteArrayInputStream) PlatformServiceContainer(org.camunda.bpm.container.impl.spi.PlatformServiceContainer) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 4 with DeployedProcessArchive

use of org.camunda.bpm.container.impl.deployment.util.DeployedProcessArchive in project camunda-bpm-platform by camunda.

the class StartProcessApplicationServiceStep method performOperationStep.

public void performOperationStep(DeploymentOperation operationContext) {
    final AbstractProcessApplication processApplication = operationContext.getAttachment(PROCESS_APPLICATION);
    final Map<URL, ProcessesXml> processesXmls = operationContext.getAttachment(PROCESSES_XML_RESOURCES);
    final Map<String, DeployedProcessArchive> processArchiveDeploymentMap = operationContext.getAttachment(PROCESS_ARCHIVE_DEPLOYMENT_MAP);
    final PlatformServiceContainer serviceContainer = operationContext.getServiceContainer();
    ProcessApplicationInfoImpl processApplicationInfo = createProcessApplicationInfo(processApplication, processArchiveDeploymentMap);
    // create service
    JmxManagedProcessApplication mbean = new JmxManagedProcessApplication(processApplicationInfo, processApplication.getReference());
    mbean.setProcessesXmls(new ArrayList<ProcessesXml>(processesXmls.values()));
    mbean.setDeploymentMap(processArchiveDeploymentMap);
    // start service
    serviceContainer.startService(ServiceTypes.PROCESS_APPLICATION, processApplication.getName(), mbean);
    notifyBpmPlatformPlugins(serviceContainer, processApplication);
}
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) ProcessApplicationInfoImpl(org.camunda.bpm.application.impl.ProcessApplicationInfoImpl) JmxManagedProcessApplication(org.camunda.bpm.container.impl.jmx.services.JmxManagedProcessApplication) URL(java.net.URL)

Example 5 with DeployedProcessArchive

use of org.camunda.bpm.container.impl.deployment.util.DeployedProcessArchive in project camunda-bpm-platform by camunda.

the class UndeployProcessArchiveStep method performOperationStep.

public void performOperationStep(DeploymentOperation operationContext) {
    final PlatformServiceContainer serviceContainer = operationContext.getServiceContainer();
    final Map<String, DeployedProcessArchive> processArchiveDeploymentMap = deployedProcessApplication.getProcessArchiveDeploymentMap();
    final DeployedProcessArchive deployedProcessArchive = processArchiveDeploymentMap.get(processArchive.getName());
    final ProcessEngine processEngine = serviceContainer.getServiceValue(ServiceTypes.PROCESS_ENGINE, processEngineName);
    // unregrister with the process engine.
    processEngine.getManagementService().unregisterProcessApplication(deployedProcessArchive.getAllDeploymentIds(), true);
    // delete the deployment if not disabled
    if (PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_DELETE_UPON_UNDEPLOY, false)) {
        if (processEngine != null) {
            // always cascade & skip custom listeners
            deleteDeployment(deployedProcessArchive.getPrimaryDeploymentId(), processEngine.getRepositoryService());
        }
    }
}
Also used : DeployedProcessArchive(org.camunda.bpm.container.impl.deployment.util.DeployedProcessArchive) PlatformServiceContainer(org.camunda.bpm.container.impl.spi.PlatformServiceContainer) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Aggregations

DeployedProcessArchive (org.camunda.bpm.container.impl.deployment.util.DeployedProcessArchive)5 PlatformServiceContainer (org.camunda.bpm.container.impl.spi.PlatformServiceContainer)4 AbstractProcessApplication (org.camunda.bpm.application.AbstractProcessApplication)3 ProcessApplicationInfoImpl (org.camunda.bpm.application.impl.ProcessApplicationInfoImpl)2 ProcessesXml (org.camunda.bpm.application.impl.metadata.spi.ProcessesXml)2 JmxManagedProcessApplication (org.camunda.bpm.container.impl.jmx.services.JmxManagedProcessApplication)2 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ProcessApplicationDeploymentInfo (org.camunda.bpm.application.ProcessApplicationDeploymentInfo)1 ProcessApplicationDeploymentInfoImpl (org.camunda.bpm.application.impl.ProcessApplicationDeploymentInfoImpl)1 ProcessArchiveXml (org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml)1 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 ProcessApplicationDeploymentBuilder (org.camunda.bpm.engine.repository.ProcessApplicationDeploymentBuilder)1