jbpm4.4部署过程详情

根据ProcessEngine取得RepositoryService加载资源文件;

String deployId = processEngine.getRepositoryService().createDeployment()
	.addResourceFromClasspath("resources/jbpm/Appropriation.jpdl.xml").deploy();



部署成功回返回流程id;

该方法的执行流程如下:

1、调用DeploymentImpl类的deploy方法;

public String deploy() {
    return commandService.execute(new DeployCmd(this));
  }



执行部署命令DeployCmd的execute方法;
public String execute(Environment environment) throws Exception {
    RepositorySession repositorySession = environment.get(RepositorySession.class);
    return repositorySession.deploy(deployment);
  }



2、调用RepositorySeession的deploy();参数deployment为DeployCmd的一个属性,在构造函数中初始化;

由于new DeployCmd(this)可知,deployment为DeploymentImpl的对象;

public String deploy(NewDeployment deployment) {
    DeploymentImpl deploymentImpl = (DeploymentImpl) deployment;
    
    long dbid = DbidGenerator.getDbidGenerator().getNextId();
    deploymentImpl.setDbid(dbid);
    deploymentImpl.initResourceLobDbids();
    
    session.save(deploymentImpl); // will also save the attached resources
    deployerManager.deploy(deploymentImpl);

    return deploymentImpl.getId();
  }



源码save注释有当保存deploymentImpl时同时保持相关的资源;那么再回头看DeploymentImpl类的属性有哪些;
public class DeploymentImpl extends ProblemList implements NewDeployment {

  private static final long serialVersionUID = 1L;

  public static final String KEY_PROCESS_LANGUAGE_ID = "langid";
  public static final String KEY_PROCESS_DEFINITION_ID = "pdid";
  public static final String KEY_PROCESS_DEFINITION_KEY = "pdkey";
  public static final String KEY_PROCESS_DEFINITION_VERSION = "pdversion";

  protected long dbid;
  protected String name;
  protected long timestamp;
  protected String state = Deployment.STATE_ACTIVE;
  protected Map<String, Lob> resources;

  protected CommandService commandService;
  protected Map<String, Object> objects;
  protected Set<DeploymentProperty> objectProperties;



发现一个resources的Map,Value为Lob类型;再看流程部署调用的加载部署文件方法,这个方法就在DeploymentImple类里面;
public NewDeployment addResourceFromClasspath(String resourceName) {
    addResourceFromStreamInput(resourceName, new ResourceStreamInput(resourceName));
    return this;
  }



public NewDeployment addResourceFromStreamInput(String name, StreamInput streamInput) {
    if (resources == null) {
      resources = new HashMap<String, Lob>();
    }
    InputStream inputStream = streamInput.openStream();
    try {
      byte[] bytes = IoUtil.readBytes(inputStream);

      // Since this method is probably called outside an environment block, we
      // need to generate the dbid of the Lob later (during the actual deployment).
      Lob lob = new Lob(bytes, false);
      resources.put(name, lob);
    }
    catch (IOException e) {
      throw new JbpmException("couldn't read from " + name, e);
    }
    finally {
      IoUtil.close(inputStream);
    }
    return this;
  }



不难看出资源文件类路径为key;

主要再看 protected Set<DeploymentProperty> objectProperties;这个属性;

这个类很简单;

public class DeploymentProperty implements Serializable {
  
  private static final long serialVersionUID = 1L;

  long dbid;
  protected DeploymentImpl deployment;
  protected String objectName;
  protected String key;
  protected String stringValue;
  protected Long longValue;
  ...



持久化到数据库,其中的几条记录为

资源文件xml的开头内容为

<process name="appcardJbpmFlow2" xmlns="http://jbpm.org/4.4/jpdl">



而 DeploymentProperty对应的数据记录为;



转载于:https://my.oschina.net/u/782865/blog/180797

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值