论坛首页 Java企业应用论坛

jbpm的例子之四 使用decision

浏览 1965 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2009-06-09   最后修改:2009-09-17
decision节点可以实现多路选择。

<?xml version="1.0" encoding="UTF-8"?>

<process-definition name="testDecision">

<start-state name="s">
<transition to="inputScore" />
</start-state>

<state name="inputScore">
<script>System.out.println("The process is at "+node);</script>
<transition to="decision1" />
</state>

<decision name="decision1">
<handler class="test.decision.ScoreDecisionHandler" />
<transition name="t1" to="s1" />
<transition name="t2" to="s2" />
</decision>

<node name="s1">
<script>
System.out.println("The process is at "+node);
token.signal();
</script>
<transition name="" to="End" />
</node>

<node name="s2">
<script>
System.out.println("The process is at "+node);
token.signal();
</script>
<transition name="" to="End" />
</node>

<end-state name="End"></end-state>

</process-definition>




public class ScoreDecisionHandler implements DecisionHandler {

private static final long serialVersionUID = 1L;

@Override
public String decide(ExecutionContext executionContext) throws Exception {

int score = (Integer) executionContext.getVariable("score");
if (score < 50)
return "t1";
return "t2";
}
}
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics