activiti5.0.alpha3之流程引擎建立入口

好吧,alpha1里头通过Configuration来建立流程引擎的方法被废弃了,我们重新开始。

这回的入口类是org.activiti.test.ProcessDeployer。

先说点题外话,这次的重构尽管给我的blog撰写带来了麻烦,但是设计思想绝对是优秀的。首先看原来alpha1版本中example中的各项test类都是采用的多重继承的方式,而在alpha3中使用了 ProcessDeployer 对象,这符合"优先使用组合而非继承"的设计原则。所以,牛人的代码也不是一开始就优美的,也是经过了多次重构之后,才变得精巧起来的。

切换回正题,首先我们看到的是 ProcessDeployer中的 deployProcessString方法

  /**
   * convenience method for deploying a string literal (XML) as a process
   * definition. It will be deployed with the name
   * <code>xmlString.bpmn20.xml</code>

   * 方便地将XML文件名加上 .bpmn20.xml后缀发布 流程定义
   */
  public void deployProcessString(String xmlString) {
    String resourceName = "xmlString." + BpmnDeployer.BPMN_RESOURCE_SUFFIX;//加
后缀
    createDeployment().name(resourceName).addString(resourceName, xmlString).deploy();
  }

很明显,所有的业务处理都在 createDeployment().name(resourceName).addString(resourceName, xmlString).deploy();这一句中,那么,首先是 createDeployment() 望文生义,这个应该是实现发布管理器,看源码:

  /**
   * create a {@link DeploymentBuilder} that is aware of the test context. All
   * deployments built this way in a test case will be automatically removed
   * from the engine when the test method finishes.

   * 在测试上下文中创建发布管理器。用这种方式在测试用例中创建的发布管理器会在测试方法执行完毕后被流程引擎自动移除
   */
  public DeploymentBuilder createDeployment() {
    final DeploymentBuilder builder = getProcessService().createDeployment();
    return getDeploymentBuilderProxy(builder);
  }
呃。。。什么,这只是测试用的?又是新东西。。那正式使用的在哪儿呢?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值