Activiti源码跟踪之流程部署

部署涉及到的表:ACT_GE_BYTEARRAY、ACT_RE_MODEL、ACT_RE_PROCDEF

参考:http://www.jianshu.com/p/0aeb725c1c9a

1、流程部署调用:

RepositoryService.createDeployment().deploy();



RepositoryServiceImpl的createDeployment方法返回DeploymentBuilder对象,该对象是一个部署管理接口,含有deploy()等方法。

public DeploymentBuilder createDeployment() {
    return commandExecutor.execute(new Command<DeploymentBuilder>() {
      @Override
      public DeploymentBuilder execute(CommandContext commandContext) {
        return new DeploymentBuilderImpl(RepositoryServiceImpl.this);
      }
    });
  }


DeploymentBuilderImpl的deploy方法调用repositoryService的deploy方法:

public Deployment deploy() {
    return repositoryService.deploy(this);
  }


2、RepositoryServiceImpl的deploy方法通过命令模式调用LogInterceptorSpringTransactionInterceptorCommandContextInterceptor拦截器之后,最后CommandContextInterceptor会调用DeployCmd.execute()方法


 public Deployment deploy(DeploymentBuilderImpl deploymentBuilder) {
    return commandExecutor.execute(new DeployCmd<Deployment>(deploymentBuilder));
  }

3、DeployCmd.execute():

部署使用DeploymentEntity对象。

public Deployment execute(CommandContext commandContext) {
    ......

    deployment.setNew(true);
    
    // Save the data
    commandContext
      .getDeploymentEntityManager()
      .insertDeployment(deployment);
    
    if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
	    commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
	    		ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED, deployment));
    }
    
    // Deployment settings
    Map<String, Object> deploymentSettings = new HashMap<String, Object>();
    deploymentSettings.put(DeploymentSettings.IS_BPMN20_XSD_VALIDATION_ENABLED, deploymentBuilder.isBpmn20XsdValidationEnabled());
    deploymentSettings.put(DeploymentSettings.IS_PROCESS_VALIDATION_ENABLED, deploymentBuilder.isProcessValidationEnabled());
    
    // Actually deploy
    commandContext
      .getProcessEngineConfiguration()
      .getDeploymentManager()
      .deploy(deployment, deploymentSettings);

    ......



}

deployment.setNew(true):第一次部署

insertDeployment(deployment):insert的是DeploymentEntity对象,存入表

deploymentSettings进行设置参数

deploy(deployment, deploymentSettings):部署


重点看下部署的方法:BpmnDeployer.deploy(deployment, deploymentSettings):方法很长,涉及到对Bpmn解析,对ProcessDefinitionEntity对象赋值,生成processDefinitionId并insert入库等一系列操作。其中最后几行代码:


public void deploy(DeploymentEntity deployment, Map<String, Object> deploymentSettings) {
      ......

      // Add to cache
      DeploymentManager deploymentManager = processEngineConfiguration.getDeploymentManager();
      deploymentManager.getProcessDefinitionCache().add(processDefinition.getId(), processDefinition);
      addDefinitionInfoToCache(processDefinition, processEngineConfiguration, commandContext);
     ......

}

分别将processDefinition放入DeploymentCache和ProcessDefinitionInfoCache

因为流程定义的数据不会改变,为了避免每次使用流程定义时都访问数据库,所以在流程进行部署之后,生成的流程定义会放在缓存中。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值