definitionserviceimpl.java

来自「一个java工作流引擎」· Java 代码 · 共 54 行

JAVA
54
字号
package org.jbpm.service;

import java.io.*;
import java.util.jar.*;
import org.apache.commons.logging.*;
import org.jbpm.*;
import org.jbpm.model.definition.impl.*;
import org.jbpm.persistence.*;
import org.jbpm.par.*;

public class DefinitionServiceImpl extends DefinitionReadServiceImpl implements DefinitionService {
  
  public DefinitionServiceImpl( JbpmConfiguration jbpmConfiguration ) {
    super( jbpmConfiguration );
  }

  public void deployProcessArchive(JarInputStream processArchiveStream) throws JpdlException, IOException {
    log.info( "deploying process archive" );
    PersistenceSessionTx sessionTx = persistenceSessionFactory.createPersistenceSessionTx();
    try {
      // parse the processdefinition.xml and create the object graph
      ArchiveParser archiveParser = new ArchiveParser( processArchiveStream );
      DefinitionImpl definition = archiveParser.getDefinition();
      
      // assign the version number
      int version = 1;
      DefinitionImpl latest = sessionTx.findLatestDefinition( definition.getName() );
      if ( latest != null ) {
        version = latest.getVersion().intValue() + 1;
      }
      definition.setVersion( new Integer( version ) );
      
      // save the definition (note that the SQL is not yet flushed to the database)
      sessionTx.save( definition );
      
      // save the files with the file manager
      archiveParser.storeFiles( definition.getId(), fileMgr );
      
      // TODO validate the delegations and their configurations after deploying a process archive 
      
      // aha, now the SQL is flushed to the database.
      sessionTx.commitAndClose();
      sessionTx = null;

      log.debug( "deployed process " + definition.getName() + " and assigned version number " + definition.getVersion() );
      
    } finally {
      if ( sessionTx != null ) sessionTx.rollbackAndClose();
    }
  }
  
  private static Log log = LogFactory.getLog(DefinitionServiceImpl.class);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?