配合 Join 實現流程並行分支(TaskNode、State 等可同時運行)。不支援並發子流程,官方建議自定義 TokenHandler 擴展。
Collection<String>),靈活路由。注意:jPDL 未來版本可能移除 Script 支援。execute(ExecutionContext)Token parent = context.getToken();
Collection transitionNames = (script != null) ? evalScript() : getLeavingTransitionsMap().keySet();
List forkedTokens = new ArrayList();
for (String tn : transitionNames) {
String childName = getTokenName(parent, tn); // 命名邏輯見下
Token child = new Token(parent, childName);
forkedTokens.add(new ForkedToken(child, tn));
}
for (ForkedToken ft : forkedTokens) {
leave(new ExecutionContext(ft.token), ft.leavingTransitionName); // 觸發 node-leave 事件多次
}
getTokenName(parent, transitionName)transitionName + 2、+3... 遞增直到唯一。parent.getChildren().size() + 1(純數字)。ForkedToken 為內部類,僅作為 (childToken, transitionName) 元組容器。suspend/resume 不適合(會連帶掛起 timer/task/message)。理解 Fork 源碼,有助於診斷並行分支異常、設計自定義 TokenHandler 實現並發子流程等高級需求。