AnsweredAssumed Answered

Autodeploy individual Processes

Question asked by damokles on Mar 4, 2014
Latest reply on Mar 11, 2014 by damokles
The current implementation of SpringProcessEngineConfiguration's autodeployment  is to take all deploymentResources and do a new deploy if any of the non-generated resources differ from the previous deployment. The problem that arises here is that you end up with many versions of a process even though nothing changed, since it was redeployed because some other process changed. This makes progress migration much harder, because you'll have to examine more process versions as there actually should been.

Would it be possible to enhance the autodeployment feature to allow optional individual deployments? Or are there any reasons why this option should not be implemented? The simple way to implement it would be to change the autoDeploymentResource method in SpringProcessEngineConfiguration.

Original

  protected void autoDeployResources(ProcessEngine processEngine) {
    if (deploymentResources!=null && deploymentResources.length>0) {
      RepositoryService repositoryService = processEngine.getRepositoryService();
     
      DeploymentBuilder deploymentBuilder = repositoryService
        .createDeployment()
        .enableDuplicateFiltering()
        .name(deploymentName);
     
      for (Resource resource : deploymentResources) {
        String resourceName = null;
       
        if (resource instanceof ContextResource) {
          resourceName = ((ContextResource) resource).getPathWithinContext();
         
        } else if (resource instanceof ByteArrayResource) {
          resourceName = resource.getDescription();
         
        } else {
          try {
            resourceName = resource.getFile().getAbsolutePath();
          } catch (IOException e) {
            resourceName = resource.getFilename();
          }
        }
       
        try {
          if ( resourceName.endsWith(".bar")
               || resourceName.endsWith(".zip")
               || resourceName.endsWith(".jar") ) {
            deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream()));
          } else {
            deploymentBuilder.addInputStream(resourceName, resource.getInputStream());
          }
        } catch (IOException e) {
          throw new ActivitiException("couldn't auto deploy resource '"+resource+"': "+e.getMessage(), e);
        }
      }
     
      deploymentBuilder.deploy();
    }
  }


Individual deployment

  protected void autoDeployResources(ProcessEngine processEngine) {
    if (deploymentResources!=null && deploymentResources.length>0) {
      RepositoryService repositoryService = processEngine.getRepositoryService();
     
      for (Resource resource : deploymentResources) {
        String resourceName = null;
       
        if (resource instanceof ContextResource) {
          resourceName = ((ContextResource) resource).getPathWithinContext();
         
        } else if (resource instanceof ByteArrayResource) {
          resourceName = resource.getDescription();
         
        } else {
          try {
            resourceName = resource.getFile().getAbsolutePath();
          } catch (IOException e) {
            resourceName = resource.getFilename();
          }
        }
       
        try {
          DeploymentBuilder deploymentBuilder = repositoryService
            .createDeployment()
            .enableDuplicateFiltering()
            .name(resourceName);
          if ( resourceName.endsWith(".bar")
               || resourceName.endsWith(".zip")
               || resourceName.endsWith(".jar") ) {
            deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream()));
          } else {
            deploymentBuilder.addInputStream(resourceName, resource.getInputStream());
          }
          deploymentBuilder.deploy();
        } catch (IOException e) {
          throw new ActivitiException("couldn't auto deploy resource '"+resource+"': "+e.getMessage(), e);
        }
      }     
    }
  }

Outcomes