public class XorFork extends AbstractConditionalGateway
XorForks do not need to be used necessarily in a balanced fork-join block as AndFork/OrForks do in connection
with AndJoin and CancellingDiscriminators. They may be used in pair with a XorJoin, but do not have to be. In
that respect, the XorFork may be understood as a "goto" jump statement known from older programming languages. As such, it may
be used to implement classic if-elseif-else, do-while/repeat-until or while/do constructs.
The underlying token model slightly restricts the use of "random" goto jumps. Namely, you may NOT cross balanced fork-join block
structure boundaries of AndFork and OrForks. That means, it is neither allowed to jump into a fork-join block from nodes
outside the block nor is it allowed to exit a fork-join with an XorFork jump.
The figure below depicts the five valid usage patterns of XorForks:
XorFork-XorJoin block modelling an if-elseif/if-else block
XorFork modelling an if-elseif/if-else block (semantically identical to the previous usage pattern)
XorFork modelling an if-elseif/if-else block with each subsequent branch ending implicitly.
+-(condition1)-[3]--+
[1]--[XOR] [XOR]--[6]
+-(condition2)-[4]--+
+-(condition1)-[3]--+
[1]--[XOR] [6]
+-(condition2)-[4]--+
+-(condition1)-[3]
[1]--[XOR]
+-(condition2)-[4]
[1]--[2]--[XOR]-(else)-[4]
| |(condition1)
+----<----+
+-(else)-[5]
|
[1]--[XOR]-(condition1)-[3]--[4]
| |
+----------<-----------+
+-(goto)-[5]
|
[1]--[XOR]-(condition1)-[3]--[XOR]--[4]
| |
+--------------<--------------+
Note that while an OrFork executes 0 to all subsequent branches, this kind of gateway selects 0 to 1
subsequent branches depending on the transition conditions. If no subsequent branches is selected, the incoming
token is terminated.| Constructor and Description |
|---|
XorFork(int id) |
XorFork(int id,
String name) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel(GraphEngine engine,
Token token)
Called when the
GraphEngine cancels the execution of a
Token, that is currently pointing to this node and is in a wait
state. |
void |
execute(GraphEngine engine,
Token token)
Performs node specific logic.
|
addCondition, getConditionsstoregetId, getName, toStringpublic XorFork(int id)
public XorFork(int id,
String name)
public void execute(GraphEngine engine, Token token)
NodeGraphEngineFacade#complete(WorkItem) method
must be called to continue executing the GraphInstance.engine - the GraphEngine which is performing the executiontoken - the Token which is currently executing in this nodepublic void cancel(GraphEngine engine, Token token)
NodeGraphEngine cancels the execution of a
Token, that is currently pointing to this node and is in a wait
state.engine - the GraphEngine which is performing the executiontoken - the Token pointing to this nodeCopyright © 2018. All rights reserved.