Example:Action in Activities Language Unit PartⅡ-Behavior 田11 Actions language unit 曰12 Activities 由12.1 Overview abstract syntax 12.2 Abstract Syntax 12.3 Class Descriptions 12.3.1 AcceptEventAction (as specialized) 12.3.2 Action (from CompleteActivities,FundamentalActivities Generalizations Description class in language unit 囚Atributes Associations Constraints Operations semantics in natural language Semantics Semantic Variation Points Notation Examples Rationale Changes from previous UML Tian Zhang Nanjing University 11
Tian Zhang @ Nanjing University 11 Example: Action in Activities Language Unit language unit abstract syntax class in language unit semantics in natural language
Abstract Syntax Behavior NamedElement an abstract metaclass (fromBasicBehaviors) (fromKernel) +activity (subsets owner) Activity ActivityNode an abstract class 0.1 +node subsets ownedEle me nt) Action Figure 12.2- Fundamental nodes 使用元模型给出Fundamental nodes的抽象语法 口该语法描述中同时包含了Action的抽象语法 口Action的抽象语法由多张类似的语法图定义 Tian Zhang Nanjing University 12
Tian Zhang @ Nanjing University 12 使用元模型给出Fundamental nodes的抽象语法 该语法描述中同时包含了Action的抽象语法 Action的抽象语法由多张类似的语法图定义 Abstract Syntax Figure 12.2 - Fundamental nodes an abstract class an abstract metaclass
Concrete Syntax Use of action and activity notation is optional.A textual notation may be used instead. Actions are notated as round-cornered rectangles.The name of the action or other description of it may appear in the symbol. klocalPrecondition> constraint name name ◆ klocalPostcondition constraint Tian Zhang Nanjing University 13
Tian Zhang @ Nanjing University 13 Concrete Syntax Use of action and activity notation is optional. A textual notation may be used instead. Actions are notated as round-cornered rectangles. The name of the action or other description of it may appear in the symbol
Semantics The sequencing of actions are controlled by control edges and object flow edges within activities,which carry control and object tokens respectively (see Activity).Alternatively,the sequencing of actions is controlled by structured nodes,or by a combination of structured nodes and edges.Except where noted,an action can only begin execution when all incoming control edges have tokens,and all input pins have object tokens.The action begins execution by taking tokens from its incoming control edges and input pins.When the execution of an action is complete,it offers tokens in its outgoing control edges and output pins,where they are accessible to other actions. The steps of executing an action with control and data flow are as follows: [1]An action execution is created when all its object flow and control flow prerequisites have been satisfied(implicit join). Exceptions to this are listed below.The flow prerequisite is satisfied when all of the input pins are offered tokens and accept them all at once,precluding them from being consumed by any other actions.This ensures that multiple action executions competing for tokens do not accept only some of the tokens they need to begin,causing deadlock as each execution waits for tokens that are already taken by others. [2]An action execution consumes the input control and object tokens and removes them from the sources of control edges and from input pins.The action execution is now enabled and may begin execution.If multiple control tokens are available on a single edge,they are all consumed. [3]An action continues executing until it has completed.Most actions operate only on their inputs.Some give access to a wider context,such as variables in the containing structured activity node,or the self object,which is the object owning the activity containing the executing action.The detailed semantic of execution an action and definition of completion depends on the particular subclass of action. [4]When completed,an action execution offers object tokens on all its output pins and control tokens on all its outgoing control edges (implicit fork),and it terminates.Exceptions to this are listed below.The output tokens are now available to satisfy the control or object flow prerequisites for other action executions. [5]After an action execution has terminated,its resources may be reclaimed by an implementation,but the details of resource management are not part of this specification and are properly part of an implementation profile. Tian Zhang Nanjing University 14
Tian Zhang @ Nanjing University 14 Semantics
See ValuePin and Parameter for exceptions to rule for starting action execution. If a behavior is not reentrant,then no more than one execution of it will exist at any given time.An invocation of a non- reentrant behavior does not start the behavior when the behavior is already executing.In this case,tokens control tokens are discarded,and data tokens collect at the input pins of the invocation action,if their upper bound is greater than one, or upstream otherwise.An invocation of a reentrant behavior will start a new execution of the behavior with newly arrived tokens,even if the behavior is already executing from tokens arriving at the invocation earlier. Package ExtraStructuredActivities If an exception occurs during the execution of an action,the execution of the action is abandoned and no regular output is generated by this action.If the action has an exception handler,it receives the exception object as a token.If the action has no exception handler,the exception propagates to the enclosing node and so on until it is caught by one of them.If an exception propagates out of a nested node (action,structured activity node,or activity),all tokens in the nested node are terminated.The data describing an exception is represented as an object of any class. Package CompleteActivities Streaming allows an action execution to take inputs and provide outputs while it is executing.During one execution,the action may consume multiple tokens on each streaming input and produce multiple tokens on each streaming output.See Parameter. Local preconditions and postconditions are constraints that should hold when the execution starts and completes, respectively.They hold only at the point in the flow that they are specified,not globally for other invocations of the behavior at other places in the flow or on other diagrams.Compare to pre and postconditions on Behavior(in Activities). See semantic variations below for their effect on flow. Tian Zhang Nanjing University 15
Tian Zhang @ Nanjing University 15