public static Stream getResourceAsStream(string name) { // Try the current Thread context class loader ClassLoader classLoader = Thread.CurrentThread.ContextClassLoader; Stream resourceStream = classLoader.getResourceAsStream(name); if (resourceStream == null) { // Finally, try the class loader for this class classLoader = typeof(ReflectUtil).ClassLoader; resourceStream = classLoader.getResourceAsStream(name); } return(resourceStream); }
public Stream openResource(string resource) { Stream stream = (clazz != null) ? clazz.getResourceAsStream(resource) : loader.getResourceAsStream(resource); if (stream == null) { throw new IOException("Resource not found: " + resource); } return(stream); }
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); } }
public override void createDeployment(string processArchiveName, DeploymentBuilder deploymentBuilder) { ProcessEngine processEngine = BpmPlatform.ProcessEngineService.getProcessEngine("default"); // Hack: deploy the first version of the invoice process once before the process application // is deployed the first time if (processEngine != null) { RepositoryService repositoryService = processEngine.RepositoryService; if (!isProcessDeployed(repositoryService, "invoice")) { ClassLoader classLoader = ProcessApplicationClassloader; repositoryService.createDeployment(this.Reference).addInputStream("invoice.v1.bpmn", classLoader.getResourceAsStream("invoice.v1.bpmn")).addInputStream("invoiceBusinessDecisions.dmn", classLoader.getResourceAsStream("invoiceBusinessDecisions.dmn")).addInputStream("review-invoice.cmmn", classLoader.getResourceAsStream("review-invoice.cmmn")).deploy(); } } }