Esempio n. 1
0
        public virtual void testNotNullAndNullDeploymentSourceShouldDeployNewVersion()
        {
            // given

            string key  = "process";
            string name = "my-deployment";

            BpmnModelInstance model = Bpmn.createExecutableProcess(key).done();

            ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().processDefinitionKey(key);

            DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery().deploymentName(name);

            // when

            ProcessApplicationDeployment deployment1 = repositoryService.createDeployment(processApplication.Reference).name(name).source("my-source1").addModelInstance("process.bpmn", model).enableDuplicateFiltering(true).deploy();

            assertEquals(1, processDefinitionQuery.count());
            assertEquals(1, deploymentQuery.count());

            ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.Reference).name(name).source(null).addModelInstance("process.bpmn", model).enableDuplicateFiltering(true).deploy();

            // then

            assertEquals(2, processDefinitionQuery.count());
            assertEquals(2, deploymentQuery.count());

            deleteDeployments(deployment1, deployment2);
        }
Esempio n. 2
0
        public virtual void testProcessApplicationDeploymentResumePreviousVersionsByDeploymentName()
        {
            // create initial deployment
            ProcessApplicationDeployment deployment1 = repositoryService.createDeployment(processApplication.Reference).name("deployment").addClasspathResource("org/camunda/bpm/engine/test/api/repository/version1.bpmn20.xml").deploy();

            assertThatOneProcessIsDeployed();

            // deploy update with changes:
            ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.Reference).name("deployment").enableDuplicateFiltering(false).resumePreviousVersions().resumePreviousVersionsBy(ResumePreviousBy.RESUME_BY_DEPLOYMENT_NAME).addClasspathResource("org/camunda/bpm/engine/test/api/repository/version2.bpmn20.xml").deploy();

            IList <ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionVersion().asc().list();

            // now there are 2 process definitions deployed
            assertEquals(1, processDefinitions[0].Version);
            assertEquals(2, processDefinitions[1].Version);

            // old deployment was resumed
            ProcessApplicationRegistration registration = deployment2.ProcessApplicationRegistration;
            ISet <string> deploymentIds = registration.DeploymentIds;

            assertEquals(2, deploymentIds.Count);
            assertEquals(processEngine.Name, registration.ProcessEngineName);

            deleteDeployments(deployment1, deployment2);
        }
Esempio n. 3
0
        public virtual void testProcessApplicationDeploymentResumePreviousVersionsByDeploymentNameDeployDifferentProcesses()
        {
            BpmnModelInstance            process1   = Bpmn.createExecutableProcess("process1").done();
            BpmnModelInstance            process2   = Bpmn.createExecutableProcess("process2").done();
            ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.Reference).name("deployment").addModelInstance("process1.bpmn", process1).deploy();

            assertThatOneProcessIsDeployed();

            ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.Reference).name("deployment").resumePreviousVersions().resumePreviousVersionsBy(ResumePreviousBy.RESUME_BY_DEPLOYMENT_NAME).addModelInstance("process2.bpmn", process2).deploy();

            IList <ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionVersion().asc().list();

            // now there are 2 process definitions deployed but both with version 1
            assertEquals(1, processDefinitions[0].Version);
            assertEquals(1, processDefinitions[1].Version);

            // old deployment was resumed
            ProcessApplicationRegistration registration = deployment2.ProcessApplicationRegistration;
            ISet <string> deploymentIds = registration.DeploymentIds;

            assertEquals(2, deploymentIds.Count);
            assertEquals(processEngine.Name, registration.ProcessEngineName);

            deleteDeployments(deployment, deployment2);
        }
Esempio n. 4
0
        public virtual void testProcessApplicationDeploymentResumePreviousVersionsByDeploymentNameNoResume()
        {
            BpmnModelInstance            process1   = Bpmn.createExecutableProcess("process1").done();
            ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.Reference).name("deployment").addModelInstance("process1.bpmn", process1).deploy();

            assertThatOneProcessIsDeployed();

            ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.Reference).name("anotherDeployment").resumePreviousVersions().resumePreviousVersionsBy(ResumePreviousBy.RESUME_BY_DEPLOYMENT_NAME).addModelInstance("process2.bpmn", process1).deploy();

            IList <ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionVersion().asc().list();

            // there is a new version of the process
            assertEquals(1, processDefinitions[0].Version);
            assertEquals(2, processDefinitions[1].Version);

            // but the old deployment was not resumed
            ProcessApplicationRegistration registration = deployment2.ProcessApplicationRegistration;
            ISet <string> deploymentIds = registration.DeploymentIds;

            assertEquals(1, deploymentIds.Count);
            assertEquals(deployment2.Id, deploymentIds.GetEnumerator().next());
            assertEquals(processEngine.Name, registration.ProcessEngineName);

            deleteDeployments(deployment, deployment2);
        }
Esempio n. 5
0
        public virtual void testProcessApplicationDeploymentResumePreviousVersionsDifferentKeys()
        {
            // create initial deployment
            ProcessApplicationDeployment deployment1 = repositoryService.createDeployment(processApplication.Reference).name("deployment").addClasspathResource("org/camunda/bpm/engine/test/api/repository/version1.bpmn20.xml").deploy();

            assertThatOneProcessIsDeployed();

            // deploy update with changes:
            ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.Reference).name("deployment").resumePreviousVersions().addClasspathResource("org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml").deploy();

            IList <ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionVersion().asc().list();

            // now there are 2 process definitions deployed
            assertEquals(1, processDefinitions[0].Version);
            assertEquals(1, processDefinitions[1].Version);

            // and the old deployment was not resumed
            ProcessApplicationRegistration registration = deployment2.ProcessApplicationRegistration;
            ISet <string> deploymentIds = registration.DeploymentIds;

            assertEquals(1, deploymentIds.Count);
            assertEquals(deployment2.Id, deploymentIds.GetEnumerator().next());
            assertEquals(processEngine.Name, registration.ProcessEngineName);

            deleteDeployments(deployment1, deployment2);
        }
Esempio n. 6
0
        public DeployedProcessArchive(ProcessApplicationDeployment deployment)
        {
            primaryDeploymentId = deployment.Id;
            ProcessApplicationRegistration registration = deployment.ProcessApplicationRegistration;

            allDeploymentIds  = registration.DeploymentIds;
            processEngineName = registration.ProcessEngineName;
        }
Esempio n. 7
0
        /// <summary>
        /// Test re-deployment of only those resources that have actually changed
        /// </summary>
        public virtual void testPartialChangesDeployChangedOnly()
        {
            BpmnModelInstance model1 = Bpmn.createExecutableProcess("process1").done();
            BpmnModelInstance model2 = Bpmn.createExecutableProcess("process2").done();

            // create initial deployment
            ProcessApplicationDeployment deployment1 = repositoryService.createDeployment(processApplication.Reference).name("deployment").addModelInstance("process1.bpmn20.xml", model1).addModelInstance("process2.bpmn20.xml", model2).deploy();

            BpmnModelInstance changedModel2 = Bpmn.createExecutableProcess("process2").startEvent().done();

            // second deployment with partial changes:
            ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.Reference).name("deployment").enableDuplicateFiltering(true).resumePreviousVersions().addModelInstance("process1.bpmn20.xml", model1).addModelInstance("process2.bpmn20.xml", changedModel2).deploy();

            assertEquals(3, repositoryService.createProcessDefinitionQuery().count());

            // there is one version of process1 deployed
            ProcessDefinition processDefinitionModel1 = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process1").singleResult();

            assertNotNull(processDefinitionModel1);
            assertEquals(1, processDefinitionModel1.Version);
            assertEquals(deployment1.Id, processDefinitionModel1.DeploymentId);

            // there are two versions of process2 deployed
            IList <ProcessDefinition> processDefinitionsModel2 = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process2").orderByProcessDefinitionVersion().asc().list();

            assertEquals(2, processDefinitionsModel2.Count);
            assertEquals(1, processDefinitionsModel2[0].Version);
            assertEquals(2, processDefinitionsModel2[1].Version);

            // old deployment was resumed
            ProcessApplicationRegistration registration = deployment2.ProcessApplicationRegistration;
            ISet <string> deploymentIds = registration.DeploymentIds;

            assertEquals(2, deploymentIds.Count);

            BpmnModelInstance anotherChangedModel2 = Bpmn.createExecutableProcess("process2").startEvent().endEvent().done();

            // testing with a third deployment to ensure the change check is not only performed against
            // the last version of the deployment
            ProcessApplicationDeployment deployment3 = repositoryService.createDeployment(processApplication.Reference).enableDuplicateFiltering(true).resumePreviousVersions().addModelInstance("process1.bpmn20.xml", model1).addModelInstance("process2.bpmn20.xml", anotherChangedModel2).name("deployment").deploy();

            // there should still be one version of process 1
            assertEquals(1, repositoryService.createProcessDefinitionQuery().processDefinitionKey("process1").count());

            // there should be three versions of process 2
            assertEquals(3, repositoryService.createProcessDefinitionQuery().processDefinitionKey("process2").count());

            // old deployments are resumed
            registration  = deployment3.ProcessApplicationRegistration;
            deploymentIds = registration.DeploymentIds;
            assertEquals(3, deploymentIds.Count);

            deleteDeployments(deployment1, deployment2, deployment3);
        }
Esempio n. 8
0
        public virtual void testSimpleProcessApplicationDeployment()
        {
            ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.Reference).addClasspathResource("org/camunda/bpm/engine/test/api/repository/version1.bpmn20.xml").deploy();

            // process is deployed:
            assertThatOneProcessIsDeployed();

            // registration was performed:
            ProcessApplicationRegistration registration = deployment.ProcessApplicationRegistration;
            ISet <string> deploymentIds = registration.DeploymentIds;

            assertEquals(1, deploymentIds.Count);
            assertEquals(processEngine.Name, registration.ProcessEngineName);

            deleteDeployments(deployment);
        }
Esempio n. 9
0
        public virtual void testPartialChangesResumePreviousVersionByDeploymentName()
        {
            BpmnModelInstance model1 = Bpmn.createExecutableProcess("process1").done();
            BpmnModelInstance model2 = Bpmn.createExecutableProcess("process2").done();

            // create initial deployment
            ProcessApplicationDeployment deployment1 = repositoryService.createDeployment(processApplication.Reference).name("deployment").addModelInstance("process1.bpmn20.xml", model1).deploy();

            ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.Reference).name("deployment").enableDuplicateFiltering(true).resumePreviousVersions().resumePreviousVersionsBy(ResumePreviousBy.RESUME_BY_DEPLOYMENT_NAME).addModelInstance("process1.bpmn20.xml", model1).addModelInstance("process2.bpmn20.xml", model2).deploy();

            ProcessApplicationRegistration registration = deployment2.ProcessApplicationRegistration;

            assertEquals(2, registration.DeploymentIds.Count);

            deleteDeployments(deployment1, deployment2);
        }
Esempio n. 10
0
        public virtual void testProcessApplicationDeploymentNoChanges()
        {
            // create initial deployment
            ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.Reference).name("deployment").addClasspathResource("org/camunda/bpm/engine/test/api/repository/version1.bpmn20.xml").deploy();

            assertThatOneProcessIsDeployed();

            // deploy update with no changes:
            deployment = repositoryService.createDeployment(processApplication.Reference).name("deployment").enableDuplicateFiltering(false).addClasspathResource("org/camunda/bpm/engine/test/api/repository/version1.bpmn20.xml").deploy();

            // no changes
            assertThatOneProcessIsDeployed();
            ProcessApplicationRegistration registration = deployment.ProcessApplicationRegistration;
            ISet <string> deploymentIds = registration.DeploymentIds;

            assertEquals(1, deploymentIds.Count);
            assertEquals(processEngine.Name, registration.ProcessEngineName);

            deleteDeployments(deployment);
        }
Esempio n. 11
0
        public virtual void testDisabledPaEnvScriptCaching()
        {
            // given
            processEngineConfiguration.EnableFetchScriptEngineFromProcessApplication = false;

            EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication();

            ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.Reference).addClasspathResource(PROCESS_PATH).deploy();

            // when
            executeScript(processApplication);

            // then
            IDictionary <string, IList <ExecutableScript> > environmentScripts = processApplication.EnvironmentScripts;

            assertNotNull(environmentScripts);
            assertNull(environmentScripts[SCRIPT_LANGUAGE]);

            repositoryService.deleteDeployment(deployment.Id, true);

            processEngineConfiguration.EnableFetchScriptEngineFromProcessApplication = true;
        }
Esempio n. 12
0
        public virtual void testCmmnDisabled()
        {
            ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.Reference).addClasspathResource("org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml").deploy();

            // process is deployed:
            ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();

            assertNotNull(processDefinition);
            assertEquals(1, processDefinition.Version);

            try
            {
                repositoryService.createCaseDefinitionQuery().singleResult();
                fail("Cmmn Disabled: It should not be possible to query for a case definition.");
            }
            catch (Exception)
            {
                // expected
            }

            repositoryService.deleteDeployment(deployment.Id, true);
        }
Esempio n. 13
0
        public virtual void testPartialChangesDeployAll()
        {
            BpmnModelInstance model1 = Bpmn.createExecutableProcess("process1").done();
            BpmnModelInstance model2 = Bpmn.createExecutableProcess("process2").done();

            // create initial deployment
            ProcessApplicationDeployment deployment1 = repositoryService.createDeployment(processApplication.Reference).name("deployment").addModelInstance("process1.bpmn20.xml", model1).addModelInstance("process2.bpmn20.xml", model2).deploy();

            BpmnModelInstance changedModel2 = Bpmn.createExecutableProcess("process2").startEvent().done();

            // second deployment with partial changes:
            ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.Reference).name("deployment").enableDuplicateFiltering(false).resumePreviousVersions().addModelInstance("process1.bpmn20.xml", model1).addModelInstance("process2.bpmn20.xml", changedModel2).deploy();

            assertEquals(4, repositoryService.createProcessDefinitionQuery().count());

            IList <ProcessDefinition> processDefinitionsModel1 = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process1").orderByProcessDefinitionVersion().asc().list();

            // now there are two versions of process1 deployed
            assertEquals(2, processDefinitionsModel1.Count);
            assertEquals(1, processDefinitionsModel1[0].Version);
            assertEquals(2, processDefinitionsModel1[1].Version);

            // now there are two versions of process2 deployed
            IList <ProcessDefinition> processDefinitionsModel2 = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process1").orderByProcessDefinitionVersion().asc().list();

            assertEquals(2, processDefinitionsModel2.Count);
            assertEquals(1, processDefinitionsModel2[0].Version);
            assertEquals(2, processDefinitionsModel2[1].Version);

            // old deployment was resumed
            ProcessApplicationRegistration registration = deployment2.ProcessApplicationRegistration;
            ISet <string> deploymentIds = registration.DeploymentIds;

            assertEquals(2, deploymentIds.Count);
            assertEquals(processEngine.Name, registration.ProcessEngineName);

            deleteDeployments(deployment1, deployment2);
        }
Esempio n. 14
0
        public virtual void testEnabledPaEnvScriptCaching()
        {
            // given
            EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication();

            ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.Reference).addClasspathResource(PROCESS_PATH).deploy();

            // when
            executeScript(processApplication);

            // then
            IDictionary <string, IList <ExecutableScript> > environmentScripts = processApplication.EnvironmentScripts;

            assertNotNull(environmentScripts);

            IList <ExecutableScript> groovyEnvScripts = environmentScripts[SCRIPT_LANGUAGE];

            assertNotNull(groovyEnvScripts);
            assertFalse(groovyEnvScripts.Count == 0);
            assertEquals(processEngineConfiguration.EnvScriptResolvers.Count, groovyEnvScripts.Count);

            repositoryService.deleteDeployment(deployment.Id, true);
        }
Esempio n. 15
0
        public virtual void testVariableInstanceQuery()
        {
            ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.Reference).addClasspathResource("org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml").deploy();

            VariableMap     variables       = Variables.createVariables().putValue("my-variable", "a-value");
            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);

            // variable instance query
            IList <VariableInstance> result = runtimeService.createVariableInstanceQuery().list();

            assertEquals(1, result.Count);

            VariableInstance variableInstance = result[0];

            assertEquals("my-variable", variableInstance.Name);

            // get variable
            assertNotNull(runtimeService.getVariable(processInstance.Id, "my-variable"));

            // get variable local
            assertNotNull(runtimeService.getVariableLocal(processInstance.Id, "my-variable"));

            repositoryService.deleteDeployment(deployment.Id, true);
        }
Esempio n. 16
0
        public override void performOperationStep(DeploymentOperation operationContext)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.container.impl.spi.PlatformServiceContainer serviceContainer = operationContext.getServiceContainer();
            PlatformServiceContainer serviceContainer = operationContext.ServiceContainer;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.application.AbstractProcessApplication processApplication = operationContext.getAttachment(Attachments.PROCESS_APPLICATION);
            AbstractProcessApplication processApplication = operationContext.getAttachment(Attachments.PROCESS_APPLICATION);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final ClassLoader processApplicationClassloader = processApplication.getProcessApplicationClassloader();
            ClassLoader processApplicationClassloader = processApplication.ProcessApplicationClassloader;

            ProcessEngine processEngine = getProcessEngine(serviceContainer, processApplication.DefaultDeployToEngineName);

            // start building deployment map
            IDictionary <string, sbyte[]> deploymentMap = new Dictionary <string, sbyte[]>();

            // add all processes listed in the processes.xml
            IList <string> listedProcessResources = processArchive.ProcessResourceNames;

            foreach (string processResource in listedProcessResources)
            {
                Stream resourceAsStream = null;
                try
                {
                    resourceAsStream = processApplicationClassloader.getResourceAsStream(processResource);
                    sbyte[] bytes = IoUtil.readInputStream(resourceAsStream, processResource);
                    deploymentMap[processResource] = bytes;
                }
                finally
                {
                    IoUtil.closeSilently(resourceAsStream);
                }
            }

            // scan for additional process definitions if not turned off
            if (PropertyHelper.getBooleanProperty(processArchive.Properties, org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml_Fields.PROP_IS_SCAN_FOR_PROCESS_DEFINITIONS, true))
            {
                string   paResourceRoot             = processArchive.Properties[org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml_Fields.PROP_RESOURCE_ROOT_PATH];
                string[] additionalResourceSuffixes = StringUtil.Split(processArchive.Properties[org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml_Fields.PROP_ADDITIONAL_RESOURCE_SUFFIXES], org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml_Fields.PROP_ADDITIONAL_RESOURCE_SUFFIXES_SEPARATOR);
//JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'putAll' method:
                deploymentMap.putAll(findResources(processApplicationClassloader, paResourceRoot, additionalResourceSuffixes));
            }

            // perform process engine deployment
            RepositoryService repositoryService = processEngine.RepositoryService;
            ProcessApplicationDeploymentBuilder deploymentBuilder = repositoryService.createDeployment(processApplication.Reference);

            // set the name for the deployment
            string deploymentName = processArchive.Name;

            if (string.ReferenceEquals(deploymentName, null) || deploymentName.Length == 0)
            {
                deploymentName = processApplication.Name;
            }
            deploymentBuilder.name(deploymentName);

            // set the tenant id for the deployment
            string tenantId = processArchive.TenantId;

            if (!string.ReferenceEquals(tenantId, null) && tenantId.Length > 0)
            {
                deploymentBuilder.tenantId(tenantId);
            }

            // enable duplicate filtering
            deploymentBuilder.enableDuplicateFiltering(PropertyHelper.getBooleanProperty(processArchive.Properties, org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml_Fields.PROP_IS_DEPLOY_CHANGED_ONLY, false));

            if (PropertyHelper.getBooleanProperty(processArchive.Properties, org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml_Fields.PROP_IS_RESUME_PREVIOUS_VERSIONS, true))
            {
                enableResumingOfPreviousVersions(deploymentBuilder);
            }

            // add all resources obtained through the processes.xml and through scanning
            foreach (KeyValuePair <string, sbyte[]> deploymentResource in deploymentMap.SetOfKeyValuePairs())
            {
                deploymentBuilder.addInputStream(deploymentResource.Key, new MemoryStream(deploymentResource.Value));
            }

            // allow the process application to add additional resources to the deployment
            processApplication.createDeployment(processArchive.Name, deploymentBuilder);

            ICollection <string> deploymentResourceNames = deploymentBuilder.ResourceNames;

            if (deploymentResourceNames.Count > 0)
            {
                LOG.deploymentSummary(deploymentResourceNames, deploymentName);

                // perform the process engine deployment
                deployment = deploymentBuilder.deploy();

                // add attachment
                IDictionary <string, DeployedProcessArchive> processArchiveDeploymentMap = operationContext.getAttachment(Attachments.PROCESS_ARCHIVE_DEPLOYMENT_MAP);
                if (processArchiveDeploymentMap == null)
                {
                    processArchiveDeploymentMap = new Dictionary <string, DeployedProcessArchive>();
                    operationContext.addAttachment(Attachments.PROCESS_ARCHIVE_DEPLOYMENT_MAP, processArchiveDeploymentMap);
                }
                processArchiveDeploymentMap[processArchive.Name] = new DeployedProcessArchive(deployment);
            }
            else
            {
                LOG.notCreatingPaDeployment(processApplication.Name);
            }
        }
Esempio n. 17
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void performDeployment() throws org.jboss.msc.service.StartException
        protected internal virtual void performDeployment()
        {
            ManagedReference reference = null;

            try
            {
                // get process engine
                ProcessEngine processEngine = processEngineInjector.Value;

                // get the process application component
                ProcessApplicationInterface processApplication = null;
                ComponentView componentView = paComponentViewInjector.OptionalValue;
                if (componentView != null)
                {
                    reference          = componentView.createInstance();
                    processApplication = (ProcessApplicationInterface)reference.Instance;
                }
                else
                {
                    processApplication = noViewProcessApplication.Value;
                }

                // get the application name
                string processApplicationName = processApplication.Name;

                // build the deployment
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.RepositoryService repositoryService = processEngine.getRepositoryService();
                RepositoryService repositoryService = processEngine.RepositoryService;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.repository.ProcessApplicationDeploymentBuilder deploymentBuilder = repositoryService.createDeployment(processApplication.getReference());
                ProcessApplicationDeploymentBuilder deploymentBuilder = repositoryService.createDeployment(processApplication.Reference);

                // enable duplicate filtering
                deploymentBuilder.enableDuplicateFiltering(PropertyHelper.getBooleanProperty(processArchive.Properties, org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml_Fields.PROP_IS_DEPLOY_CHANGED_ONLY, false));

                // enable resuming of previous versions:
                if (PropertyHelper.getBooleanProperty(processArchive.Properties, org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml_Fields.PROP_IS_RESUME_PREVIOUS_VERSIONS, true))
                {
                    enableResumingOfPreviousVersions(deploymentBuilder);
                }

                // set the name for the deployment
                string deploymentName = processArchive.Name;
                if (string.ReferenceEquals(deploymentName, null) || deploymentName.Length == 0)
                {
                    deploymentName = processApplicationName;
                }
                deploymentBuilder.name(deploymentName);

                // set the tenant id for the deployment
                string tenantId = processArchive.TenantId;
                if (!string.ReferenceEquals(tenantId, null) && tenantId.Length > 0)
                {
                    deploymentBuilder.tenantId(tenantId);
                }

                // add deployment resources
                foreach (KeyValuePair <string, sbyte[]> resource in deploymentMap.SetOfKeyValuePairs())
                {
                    deploymentBuilder.addInputStream(resource.Key, new MemoryStream(resource.Value));
                }

                // let the process application component add resources to the deployment.
                processApplication.createDeployment(processArchive.Name, deploymentBuilder);

                ICollection <string> resourceNames = deploymentBuilder.ResourceNames;
                if (resourceNames.Count > 0)
                {
                    logDeploymentSummary(resourceNames, deploymentName, processApplicationName);
                    // perform the actual deployment
                    deployment = Tccl.runUnderClassloader(new OperationAnonymousInnerClass(this, deploymentBuilder)
                                                          , module.ClassLoader);
                }
                else
                {
                    LOGGER.info("Not creating a deployment for process archive '" + processArchive.Name + "': no resources provided.");
                }
            }
            catch (Exception e)
            {
                throw new StartException("Could not register process application with shared process engine ", e);
            }
            finally
            {
                if (reference != null)
                {
                    reference.release();
                }
            }
        }
Esempio n. 18
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void start(org.jboss.msc.service.StartContext context) throws org.jboss.msc.service.StartException
        public override void start(StartContext context)
        {
            ManagedReference reference = null;

            try
            {
                // get the process application component
                ProcessApplicationInterface processApplication = null;
                ComponentView componentView = paComponentViewInjector.OptionalValue;
                if (componentView != null)
                {
                    reference          = componentView.createInstance();
                    processApplication = (ProcessApplicationInterface)reference.Instance;
                }
                else
                {
                    processApplication = noViewProcessApplication.Value;
                }

                // create & populate the process application info object
                processApplicationInfo            = new ProcessApplicationInfoImpl();
                processApplicationInfo.Name       = processApplication.Name;
                processApplicationInfo.Properties = processApplication.Properties;

                referencedProcessEngines = new HashSet <ProcessEngine>();
                IList <ProcessApplicationDeploymentInfo> deploymentInfos = new List <ProcessApplicationDeploymentInfo>();

                foreach (ServiceName deploymentServiceName in deploymentServiceNames)
                {
                    ProcessApplicationDeploymentService value = getDeploymentService(context, deploymentServiceName);
                    referencedProcessEngines.Add(value.ProcessEngineInjector.Value);

                    ProcessApplicationDeployment deployment = value.Deployment;
                    if (deployment != null)
                    {
                        foreach (string deploymentId in deployment.ProcessApplicationRegistration.DeploymentIds)
                        {
                            ProcessApplicationDeploymentInfoImpl deploymentInfo = new ProcessApplicationDeploymentInfoImpl();
                            deploymentInfo.DeploymentId      = deploymentId;
                            deploymentInfo.ProcessEngineName = value.ProcessEngineName;
                            deploymentInfos.Add(deploymentInfo);
                        }
                    }
                }
                processApplicationInfo.DeploymentInfo = deploymentInfos;

                notifyBpmPlatformPlugins(platformPluginsInjector.Value, processApplication);

                if (postDeployDescription != null)
                {
                    invokePostDeploy(processApplication);
                }

                // install the ManagedProcessApplication Service as a child to this service
                // if this service stops (at undeployment) the ManagedProcessApplication service is removed as well.
                ServiceName serviceName = ServiceNames.forManagedProcessApplication(processApplicationInfo.Name);
                MscManagedProcessApplication managedProcessApplication = new MscManagedProcessApplication(processApplicationInfo, processApplication.Reference);
                context.ChildTarget.addService(serviceName, managedProcessApplication).install();
            }
            catch (StartException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new StartException(e);
            }
            finally
            {
                if (reference != null)
                {
                    reference.release();
                }
            }
        }