cancel
Showing results for 
Search instead for 
Did you mean: 

Autodeploy individual Processes

damokles
Champ in-the-making
Champ in-the-making
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);
        }
      }     
    }
  }
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
Is ti possible to create a pull-request with the changes above, with some comments? Much easier to see what changed an why, while allowing us to track the author and pull it in easily.

damokles
Champ in-the-making
Champ in-the-making