jbpm備忘録2 Nodeとアクション
ノードに対してactionを設定せずに、node-enterイベントに紐づけたActionHandlerの内部でleaveNodeするようにしたフローを実行すると、後続のノードに設定したActionHandlerが2度実行されているようで、期待している動作とは、ちょっと違った動きをしたので、調査してみた。
org.jbpm.graph.def.Nodeの実装を確認して、その理由がわかった。
org.jbpm.graph.def.Nodeのexecuteメソッドは以下とおりでactionを指定していない場合leaveしているためだ。
これなら当然、executeとActionHanlderとで、2回分のleaveNodeが実行されるわけだ。
public void execute(ExecutionContext executionContext) { // if there is a custom action associated with this node if (action != null) { // execute the action executeAction(action, executionContext); } else { // leave the node over the default transition leave(executionContext); } }
結論:ノードにactionを指定しないのであればActionHandlerでleaveNodeは不要。