Section 9.2. Tokens


9.2. Tokens

Conceptually, UML models information moving along an edge as a token. A token may represent real data, an object, or the focus of control. An action typically has a set of required inputs and doesn't begin executing until the inputs are met. Likewise, when an action completes, it typically generates outputs that may trigger other actions to start. The inputs and outputs of an action are represented as tokens.

Each edge may have a weight associated with it that indicates how many tokens must be available before the tokens are presented to the target action. You show a weight by placing the keyword weight in curly brackets ({}) equal to the desired number of tokens. A weight of null indicates all tokens should be made available to the target action as soon as they arrive. For example, Figure 9-12 shows that nine players are needed before you can make a baseball team.

Figure 9-12. Activity diagram with edge weights


In addition to weights, each edge may have a guard condition that is tested against all tokens. If the guard condition fails, the token is destroyed. If the condition passes, the token is available to be consumed by the next action. If a weight is associated with the edge, the tokens aren't tested against the guard condition until enough tokens are available to satisfy the weight. Each token is tested individually, and if one fails, it is removed from the pool of available tokens. If this reduces the number of tokens available to less than the weight for the edge, all the tokens are held until enough are available. You show a guard condition by putting a boolean expression in brackets ([]) near the activity edge. Guard conditions are typically used with decision nodes to control the flow of an activity (see "Decision and merge nodes").




UML 2.0 in a Nutshell
UML 2.0 in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596007957
EAN: 2147483647
Year: 2005
Pages: 132

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net