Jbpm建模添加action和task的说明(自己理解和测试的:)

state 节点中无法直接添加Action
如下写法"  <state name='s'>" +
       "    <action class='org.jbpm.tutorial.action.MyActionHandler' />" +
       "    <transition to='end'>" +
       "    </transition>" +
       "  </state>" +
是错误的

task-node节点中无法直接添加Action
       "  <task-node name='s'>" +
       "    <action class='org.jbpm.tutorial.action.MyActionHandler' />" +
       "    <transition to='end'>" +
       "    </transition>" +
       "  </task-node>" +
是错误的

以上在流程定义里面添加,运行的时候并不报错,但是却没有执行,所以我认为是错误的。


node节点中可以直接添加Action
       "  <node name='s'>" +
       "    <action class='org.jbpm.tutorial.action.MyActionHandler' />" +
       "    <transition to='end'>" +
       "    </transition>" +
       "  </node>" +
是正确的
但运行的时候,当运行到node里面的action的时候,执行完action流程会停在这里,需要再次调用token.signal()才能继续运行。
这也就是jbpm3.1用户手册上面说道的
“Note the difference between an action that is placed in an event versus an action that is placed in a node. Actions that are put in an event are executed when the event fires. Actions on events have no way to influence the flow of control of the process. It is similar to the observer pattern. On the other hand, an action that is put on a node has the responsibility of propagating the execution.”

=============
从jbpm在eclipse的建模工具中看,只有task-node是可以添加task的。所有的节点都可以添加action。但建模工具中所有的节点都只能在event中添加action。但其实在node节点中可以直接添加action的。估计是建模工具的一个遗漏吧。不知道我这么说对不对。

===========
对于这样的流程
     "<process-definition>" +
      "  <start-state>" +
      "    <transition to='s' />" +
      "  </start-state>" +
      "  <state name='s'>" +
      "    <transition to='end'>" +
      "      <action class='org.jbpm.tutorial.action.MyActionHandler' />" +
      "    </transition>" +
      "  </state>" +
      "  <end-state name='end' />" +
      "</process-definition>"
     
      因为使用的state节点,所以需要两次调用token.signal()才能运行结束。第一调用token.signal会在进入state节点后停住,等待第二次的token.signal();
      但如果吧state节点换成node节点,那么只需要一次token.signal()就可以执行完毕了。
      这就是jbpm用户手册所说的state节点和node节点的区别
      “A state is a bare-bones wait state. The difference with a task node is that no task instances will be created in any task list. This can be usefull if the process should wait for an external system.”
      另外,把state节点替换为task-node节点,其性质和node节点一样,在没有task的时候,也都是自动执行,不等待。
      注意:task-node被归类为一个等待节点,是指在task-node中的task列表中的task没有全部执行完之前,它会一直等待。
      “The task-node is a node in JPDL that represents a wait state and generates task(s) to be completed before the process can continue to execute.  ” 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值