andywei520
andywei520
2010-08-05 22:17
浏览 271
已采纳

JBpm部署流程后,其他的表都有值,jbpm4_deployprop表为空

我采用的以下方式,部署流程
InputStream is = new ByteArrayInputStream(definitionXml.getBytes());
repositoryService.createDeployment().addResourceFromInputStream("process", is).deploy();

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • oyj7454103
    oyj7454103 2010-08-06 09:05
    已采纳

    问题就出在参数resourceName:process上,JBPM部署时会判断resourceName是否以“.jpdl.xml“作为后缀,如果是,JBPM才会解析第二个参数为流程定义,否则不做处理。所以在jbpm4_deployprop就不会有数据了。JBPM相关源码在ProcessDeployer.java中如下:

    Java代码
    @SuppressWarnings("unchecked")

    public void deploy(DeploymentImpl deployment) {

    for (String resourceName: deployment.getResourceNames()) {

    if (resourceName.endsWith(extension)) {   
      byte[] bytes = deployment.getBytes(resourceName);   
      InputStream inputStream = new ByteArrayInputStream(bytes);   
      Parse parse = parser.createParse();   
      parse.contextMapPut(Parse.CONTEXT_KEY_DEPLOYMENT, deployment);   
      parse.setProblems(deployment.getProblems());   
      parse.setInputStream(inputStream);   
      parse.execute();   
      List<ProcessDefinitionImpl> processDefinitions = (List<ProcessDefinitionImpl>) parse.getDocumentObject();   
      if (processDefinitions!=null) {   
        for (ProcessDefinitionImpl processDefinition : processDefinitions) {   
          if ((processDefinition != null) && (processDefinition.getName() != null)) {   
            String processDefinitionName = processDefinition.getName();   
    
            processDefinition.setSuspended(deployment.isSuspended());   
    
            String imageResourceName = resourceName.substring(0, resourceName.lastIndexOf(extension)) + ".png";   
            if (deployment.getResourceNames().contains(imageResourceName)) {   
              processDefinition.setImageResourceName(imageResourceName);   
            }   
    
            processDefinition.setDeploymentDbid(deployment.getDbid());   
    
            if (deployment.hasObjectProperties(processDefinitionName)) {   
              String key = deployment.getProcessDefinitionKey(processDefinitionName);   
              String id = deployment.getProcessDefinitionId(processDefinitionName);   
              Long version = deployment.getProcessDefinitionVersion(processDefinitionName);   
              processDefinition.setId(id);   
              processDefinition.setKey(key);   
              processDefinition.setVersion(version.intValue());   
    
            } else {   
              checkKey(processDefinition, deployment);   
              checkVersion(processDefinition, deployment);   
              checkId(processDefinition, deployment);   
    
              deployment.setProcessDefinitionId(processDefinitionName, processDefinition.getId());   
              deployment.setProcessDefinitionKey(processDefinitionName, processDefinition.getKey());   
              deployment.setProcessDefinitionVersion(processDefinitionName, new Long(processDefinition.getVersion()));   
    
              //execute migration   
              Map<ProcessDefinition, MigrationDescriptor> migrations = (Map<ProcessDefinition, MigrationDescriptor>)parse.contextMapGet(Parse.CONTEXT_KEY_MIGRATIONS);   
              if (migrations != null) {   
                MigrationDescriptor migrationDescriptor = migrations.get(processDefinition);   
                if (migrationDescriptor != null) {   
                  InstanceMigrator.migrateAll(processDefinition, migrationDescriptor);   
                }   
              }   
    
            }   
    
            deployment.addObject(processDefinitionName, processDefinition);   
          }   
        }   
      }   
    }   
    

    }

    }

    @SuppressWarnings("unchecked")
    public void deploy(DeploymentImpl deployment) {

    for (String resourceName: deployment.getResourceNames()) {
    
      if (resourceName.endsWith(extension)) {
        byte[] bytes = deployment.getBytes(resourceName);
        InputStream inputStream = new ByteArrayInputStream(bytes);
        Parse parse = parser.createParse();
        parse.contextMapPut(Parse.CONTEXT_KEY_DEPLOYMENT, deployment);
        parse.setProblems(deployment.getProblems());
        parse.setInputStream(inputStream);
        parse.execute();
        List<ProcessDefinitionImpl> processDefinitions = (List<ProcessDefinitionImpl>) parse.getDocumentObject();
        if (processDefinitions!=null) {
          for (ProcessDefinitionImpl processDefinition : processDefinitions) {
            if ((processDefinition != null) && (processDefinition.getName() != null)) {
              String processDefinitionName = processDefinition.getName();
    
              processDefinition.setSuspended(deployment.isSuspended());
    
              String imageResourceName = resourceName.substring(0, resourceName.lastIndexOf(extension)) + ".png";
              if (deployment.getResourceNames().contains(imageResourceName)) {
                processDefinition.setImageResourceName(imageResourceName);
              }
    
              processDefinition.setDeploymentDbid(deployment.getDbid());
    
              if (deployment.hasObjectProperties(processDefinitionName)) {
                String key = deployment.getProcessDefinitionKey(processDefinitionName);
                String id = deployment.getProcessDefinitionId(processDefinitionName);
                Long version = deployment.getProcessDefinitionVersion(processDefinitionName);
                processDefinition.setId(id);
                processDefinition.setKey(key);
                processDefinition.setVersion(version.intValue());
    
              } else {
                checkKey(processDefinition, deployment);
                checkVersion(processDefinition, deployment);
                checkId(processDefinition, deployment);
    
                deployment.setProcessDefinitionId(processDefinitionName, processDefinition.getId());
                deployment.setProcessDefinitionKey(processDefinitionName, processDefinition.getKey());
                deployment.setProcessDefinitionVersion(processDefinitionName, new Long(processDefinition.getVersion()));
    
                //execute migration
                Map<ProcessDefinition, MigrationDescriptor> migrations = (Map<ProcessDefinition, MigrationDescriptor>)parse.contextMapGet(Parse.CONTEXT_KEY_MIGRATIONS);
                if (migrations != null) {
                  MigrationDescriptor migrationDescriptor = migrations.get(processDefinition);
                  if (migrationDescriptor != null) {
                    InstanceMigrator.migrateAll(processDefinition, migrationDescriptor);
                  }
                }
    
              }
    
              deployment.addObject(processDefinitionName, processDefinition);
            }
          }
        }
      }
    }
    

    }
    所以把 "process"改为"process.jpdl.xml"就OK了!

    点赞 评论

相关推荐