Search in sources :

Example 6 with PlatformServiceContainer

use of org.camunda.bpm.container.impl.spi.PlatformServiceContainer 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 7 with PlatformServiceContainer

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

the class DeployProcessArchiveStep method cancelOperationStep.

@Override
public void cancelOperationStep(DeploymentOperation operationContext) {
    final PlatformServiceContainer serviceContainer = operationContext.getServiceContainer();
    ProcessEngine processEngine = getProcessEngine(serviceContainer);
    // if a registration was performed, remove it.
    if (deployment != null && deployment.getProcessApplicationRegistration() != null) {
        processEngine.getManagementService().unregisterProcessApplication(deployment.getProcessApplicationRegistration().getDeploymentIds(), true);
    }
    // isDeleteUponUndeploy is set.
    if (deployment != null && PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_DELETE_UPON_UNDEPLOY, false)) {
        if (processEngine != null) {
            processEngine.getRepositoryService().deleteDeployment(deployment.getId(), true);
        }
    }
}
Also used : PlatformServiceContainer(org.camunda.bpm.container.impl.spi.PlatformServiceContainer) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 8 with PlatformServiceContainer

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

the class NotifyPostProcessApplicationUndeployedStep method performOperationStep.

@Override
public void performOperationStep(DeploymentOperation operationContext) {
    final AbstractProcessApplication processApplication = operationContext.getAttachment(Attachments.PROCESS_APPLICATION);
    final PlatformServiceContainer serviceContainer = operationContext.getServiceContainer();
    final JmxManagedBpmPlatformPlugins plugins = serviceContainer.getService(ServiceTypes.BPM_PLATFORM, RuntimeContainerDelegateImpl.SERVICE_NAME_PLATFORM_PLUGINS);
    if (plugins != null) {
        for (BpmPlatformPlugin plugin : plugins.getValue().getPlugins()) {
            plugin.postProcessApplicationUndeploy(processApplication);
        }
    }
}
Also used : BpmPlatformPlugin(org.camunda.bpm.container.impl.plugin.BpmPlatformPlugin) AbstractProcessApplication(org.camunda.bpm.application.AbstractProcessApplication) JmxManagedBpmPlatformPlugins(org.camunda.bpm.container.impl.jmx.services.JmxManagedBpmPlatformPlugins) PlatformServiceContainer(org.camunda.bpm.container.impl.spi.PlatformServiceContainer)

Example 9 with PlatformServiceContainer

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

the class StartProcessEngineStep method performOperationStep.

public void performOperationStep(DeploymentOperation operationContext) {
    final PlatformServiceContainer serviceContainer = operationContext.getServiceContainer();
    final AbstractProcessApplication processApplication = operationContext.getAttachment(PROCESS_APPLICATION);
    ClassLoader classLoader = null;
    if (processApplication != null) {
        classLoader = processApplication.getProcessApplicationClassloader();
    }
    String configurationClassName = processEngineXml.getConfigurationClass();
    if (configurationClassName == null || configurationClassName.isEmpty()) {
        configurationClassName = StandaloneProcessEngineConfiguration.class.getName();
    }
    // create & instantiate configuration class
    Class<? extends ProcessEngineConfigurationImpl> configurationClass = loadClass(configurationClassName, classLoader, ProcessEngineConfigurationImpl.class);
    ProcessEngineConfigurationImpl configuration = createInstance(configurationClass);
    // set UUid generator
    // TODO: move this to configuration and use as default?
    ProcessEngineConfigurationImpl configurationImpl = configuration;
    configurationImpl.setIdGenerator(new StrongUuidGenerator());
    // set configuration values
    String name = processEngineXml.getName();
    configuration.setProcessEngineName(name);
    String datasourceJndiName = processEngineXml.getDatasource();
    configuration.setDataSourceJndiName(datasourceJndiName);
    // apply properties
    Map<String, String> properties = processEngineXml.getProperties();
    setJobExecutorActivate(configuration, properties);
    PropertyHelper.applyProperties(configuration, properties);
    // instantiate plugins:
    configurePlugins(configuration, processEngineXml, classLoader);
    if (processEngineXml.getJobAcquisitionName() != null && !processEngineXml.getJobAcquisitionName().isEmpty()) {
        JobExecutor jobExecutor = getJobExecutorService(serviceContainer);
        ensureNotNull("Cannot find referenced job executor with name '" + processEngineXml.getJobAcquisitionName() + "'", "jobExecutor", jobExecutor);
        // set JobExecutor on process engine
        configurationImpl.setJobExecutor(jobExecutor);
    }
    // start the process engine inside the container.
    JmxManagedProcessEngine managedProcessEngineService = createProcessEngineControllerInstance(configuration);
    serviceContainer.startService(ServiceTypes.PROCESS_ENGINE, configuration.getProcessEngineName(), managedProcessEngineService);
}
Also used : AbstractProcessApplication(org.camunda.bpm.application.AbstractProcessApplication) JmxManagedProcessEngine(org.camunda.bpm.container.impl.jmx.services.JmxManagedProcessEngine) StandaloneProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration) PlatformServiceContainer(org.camunda.bpm.container.impl.spi.PlatformServiceContainer) JobExecutor(org.camunda.bpm.engine.impl.jobexecutor.JobExecutor) StrongUuidGenerator(org.camunda.bpm.engine.impl.persistence.StrongUuidGenerator) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 10 with PlatformServiceContainer

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

the class StopProcessApplicationsStep method performOperationStep.

public void performOperationStep(DeploymentOperation operationContext) {
    final PlatformServiceContainer serviceContainer = operationContext.getServiceContainer();
    List<JmxManagedProcessApplication> processApplicationsReferences = serviceContainer.getServiceValuesByType(ServiceTypes.PROCESS_APPLICATION);
    for (JmxManagedProcessApplication processApplication : processApplicationsReferences) {
        stopProcessApplication(processApplication.getProcessApplicationReference());
    }
}
Also used : PlatformServiceContainer(org.camunda.bpm.container.impl.spi.PlatformServiceContainer) JmxManagedProcessApplication(org.camunda.bpm.container.impl.jmx.services.JmxManagedProcessApplication)

Aggregations

PlatformServiceContainer (org.camunda.bpm.container.impl.spi.PlatformServiceContainer)23 AbstractProcessApplication (org.camunda.bpm.application.AbstractProcessApplication)9 JmxManagedProcessApplication (org.camunda.bpm.container.impl.jmx.services.JmxManagedProcessApplication)5 DeployedProcessArchive (org.camunda.bpm.container.impl.deployment.util.DeployedProcessArchive)4 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)4 ProcessesXml (org.camunda.bpm.application.impl.metadata.spi.ProcessesXml)3 JmxManagedBpmPlatformPlugins (org.camunda.bpm.container.impl.jmx.services.JmxManagedBpmPlatformPlugins)2 JobExecutor (org.camunda.bpm.engine.impl.jobexecutor.JobExecutor)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 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 ProcessApplicationDeploymentInfo (org.camunda.bpm.application.ProcessApplicationDeploymentInfo)1 ProcessApplicationInfo (org.camunda.bpm.application.ProcessApplicationInfo)1 ProcessApplicationInfoImpl (org.camunda.bpm.application.impl.ProcessApplicationInfoImpl)1 ProcessArchiveXml (org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml)1 JmxManagedJobExecutor (org.camunda.bpm.container.impl.jmx.services.JmxManagedJobExecutor)1