Skip to content

Commit 819a8ef

Browse files
committed
Merge pull request #36 from ModelDriven/FUML15-2
FUML15-2 The fUML subset should support the raising and handling of exceptions
2 parents fc4d814 + dc58c1a commit 819a8ef

19 files changed

Lines changed: 4309 additions & 787 deletions

org.modeldriven.fuml/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434
</attributes>
3535
</classpathentry>
3636
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
37+
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
3738
<classpathentry kind="output" path="target/classes"/>
3839
</classpath>

org.modeldriven.fuml/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>fuml</artifactId>
66
<packaging>jar</packaging>
77
<name>FUML Reference Implementation</name>
8-
<version>1.4.3</version>
8+
<version>1.4.4-SNAPSHOT</version>
99
<description>This open source software is a reference implementation, consisting of software and related files, for the OMG specification called the Semantics of a Foundational Subset for Executable UML Models (fUML). The reference implementation is intended to implement the execution semantics of UML activity models, accepting an XMI file from a conformant UML model as its input and providing an execution trace of the selected activity model(s) as its output. The core execution engine, which is directly generated from the normative syntactic and semantic models for fUML, may also be used as a library implementation of fUML in other software.</description>
1010
<url>http:/fuml.modeldriven.org</url>
1111
<licenses>

org.modeldriven.fuml/src/main/java/fuml/semantics/actions/ActionActivation.java

Lines changed: 53 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
* as stated in the file entitled Licensing-Information.
44
*
55
* Modifications:
6-
* Copyright 2009-2012 Data Access Technologies, Inc.
6+
* Copyright 2009-2017 Data Access Technologies, Inc.
77
* Copyright 2020 Model Driven Solutions, Inc.
8+
* Copyright 2020 CEA LIST.
89
*
910
* Licensed under the Academic Free License version 3.0
1011
* (http://www.opensource.org/licenses/afl-3.0.php), except as stated
@@ -45,21 +46,20 @@
4546
import fuml.syntax.structuredclassifiers.Association;
4647
import fuml.syntax.values.LiteralBoolean;
4748

48-
public abstract class ActionActivation extends
49-
fuml.semantics.activities.ActivityNodeActivation {
49+
public abstract class ActionActivation extends fuml.semantics.activities.ExecutableNodeActivation {
5050

51-
public fuml.semantics.actions.PinActivationList pinActivations = new fuml.semantics.actions.PinActivationList();
5251
public boolean firing = false;
53-
52+
public fuml.semantics.actions.PinActivationList pinActivations = new fuml.semantics.actions.PinActivationList();
53+
5454
public void initialize(ActivityNode node, ActivityNodeActivationGroup group) {
5555
// Initialize this action activation to be not firing.
56-
56+
5757
super.initialize(node, group);
5858
this.firing = false;
5959
}
6060

6161
public void run() {
62-
// Run this action activation and any outoging fork node attached to it.
62+
// Run this action activation and any outgoing fork node attached to it.
6363

6464
super.run();
6565

@@ -111,8 +111,7 @@ public fuml.semantics.activities.TokenList takeOfferedTokens() {
111111
return offeredTokens;
112112
} // takeOfferedTokens
113113

114-
public void fire(
115-
fuml.semantics.activities.TokenList incomingTokens) {
114+
public void fire(fuml.semantics.activities.TokenList incomingTokens) {
116115
// Do the main action behavior then concurrently fire all output pin
117116
// activations
118117
// and offer a single control token. Then activate the action again,
@@ -262,8 +261,7 @@ public void createNodeActivations() {
262261
}
263262
} // createNodeActivations
264263

265-
public void addOutgoingEdge(
266-
fuml.semantics.activities.ActivityEdgeInstance edge) {
264+
public void addOutgoingEdge(fuml.semantics.activities.ActivityEdgeInstance edge) {
267265
// If there are no outgoing activity edge instances, create a single
268266
// activity edge instance with a fork node execution at the other end.
269267
// Add the give edge to the fork node execution that is the target of
@@ -286,16 +284,14 @@ public void addOutgoingEdge(
286284
forkNodeActivation.addOutgoingEdge(edge);
287285
} // addOutgoingEdge
288286

289-
public void addPinActivation(
290-
fuml.semantics.actions.PinActivation pinActivation) {
287+
public void addPinActivation(fuml.semantics.actions.PinActivation pinActivation) {
291288
// Add a pin activation to this action activation.
292289

293290
this.pinActivations.addValue(pinActivation);
294291
pinActivation.actionActivation = this;
295292
} // addPinActivation
296293

297-
public fuml.semantics.actions.PinActivation getPinActivation(
298-
fuml.syntax.actions.Pin pin) {
294+
public fuml.semantics.actions.PinActivation getPinActivation(fuml.syntax.actions.Pin pin) {
299295
// Precondition: The given pin is owned by the action of the action
300296
// activation.
301297
// Return the pin activation corresponding to the given pin.
@@ -315,8 +311,7 @@ public fuml.semantics.actions.PinActivation getPinActivation(
315311

316312
} // getPinActivation
317313

318-
public void putToken(fuml.syntax.actions.OutputPin pin,
319-
fuml.semantics.values.Value value) {
314+
public void putToken(fuml.syntax.actions.OutputPin pin, fuml.semantics.values.Value value) {
320315
// Precondition: The action execution has fired and the given pin is
321316
// owned by the action of the action execution.
322317
// Place a token for the given value on the pin activation corresponding
@@ -331,8 +326,7 @@ public void putToken(fuml.syntax.actions.OutputPin pin,
331326
pinActivation.addToken(token);
332327
} // putToken
333328

334-
public void putTokens(fuml.syntax.actions.OutputPin pin,
335-
fuml.semantics.values.ValueList values) {
329+
public void putTokens(fuml.syntax.actions.OutputPin pin, fuml.semantics.values.ValueList values) {
336330
// Precondition: The action execution has fired and the given pin is
337331
// owned by the action of the action execution.
338332
// Place tokens for the given values on the pin activation corresponding
@@ -347,8 +341,7 @@ public void putTokens(fuml.syntax.actions.OutputPin pin,
347341

348342
} // putTokens
349343

350-
public fuml.semantics.values.ValueList getTokens(
351-
fuml.syntax.actions.InputPin pin) {
344+
public fuml.semantics.values.ValueList getTokens(fuml.syntax.actions.InputPin pin) {
352345
// Precondition: The action execution has fired and the given pin is
353346
// owned by the action of the action execution.
354347
// Get any tokens held by the pin activation corresponding to the given
@@ -372,8 +365,7 @@ public fuml.semantics.values.ValueList getTokens(
372365
return values;
373366
} // getTokens
374367

375-
public fuml.semantics.values.ValueList takeTokens(
376-
fuml.syntax.actions.InputPin pin) {
368+
public fuml.semantics.values.ValueList takeTokens(fuml.syntax.actions.InputPin pin) {
377369
// Precondition: The action execution has fired and the given pin is
378370
// owned by the action of the action execution.
379371
// Take any tokens held by the pin activation corresponding to the given
@@ -396,8 +388,7 @@ public fuml.semantics.values.ValueList takeTokens(
396388
return values;
397389
} // takeTokens
398390

399-
public boolean isSourceFor(
400-
fuml.semantics.activities.ActivityEdgeInstance edgeInstance) {
391+
public boolean isSourceFor(fuml.semantics.activities.ActivityEdgeInstance edgeInstance) {
401392
// If this action has an outgoing fork node, check that the fork node is
402393
// the source of the given edge instance.
403394

@@ -410,8 +401,7 @@ public boolean isSourceFor(
410401
return isSource;
411402
} // isSourceFor
412403

413-
public boolean valueParticipatesInLink(
414-
fuml.semantics.values.Value value,
404+
public boolean valueParticipatesInLink(fuml.semantics.values.Value value,
415405
fuml.semantics.structuredclassifiers.Link link) {
416406
// Test if the given value participates in the given link.
417407

@@ -537,8 +527,7 @@ public fuml.syntax.classification.Property getOppositeEnd(
537527
return oppositeEnd;
538528
} // getOppositeEnd
539529

540-
public fuml.semantics.simpleclassifiers.BooleanValue makeBooleanValue(
541-
boolean value) {
530+
public fuml.semantics.simpleclassifiers.BooleanValue makeBooleanValue(boolean value) {
542531
// Make a Boolean value using the built-in Boolean primitive type.
543532
// [This ensures that Boolean values created internally are the same as
544533
// the default used for evaluating Boolean literals.]
@@ -549,4 +538,38 @@ public fuml.semantics.simpleclassifiers.BooleanValue makeBooleanValue(
549538
.evaluate(booleanLiteral));
550539
} // makeBooleanValue
551540

552-
} // ActionActivation
541+
public void handle(fuml.semantics.values.Value exception, fuml.syntax.activities.ExceptionHandler handler) {
542+
// Handle the given exception by firing the body of the given
543+
// exception handler. After the body fires, transfer its outputs
544+
// to the output pins of this action activation.
545+
546+
super.handle(exception, handler);
547+
this.transferOutputs((Action)handler.handlerBody);
548+
}
549+
550+
public void transferOutputs(fuml.syntax.actions.Action handlerBody) {
551+
// Transfer the output values from activation of the given exception
552+
// handler body to the output pins of this action activation.
553+
554+
ActionActivation handlerBodyActivation =
555+
(ActionActivation)this.group.getNodeActivation(handlerBody);
556+
OutputPinList sourceOutputs = handlerBody.output;
557+
OutputPinList targetOutputs = ((Action) this.node).output;
558+
559+
for (int i = 0; i < sourceOutputs.size(); i++) {
560+
OutputPin sourcePin = sourceOutputs.getValue(i);
561+
OutputPin targetPin = targetOutputs.getValue(i);
562+
563+
PinActivation sourcePinActivation = handlerBodyActivation.getPinActivation(sourcePin);
564+
TokenList tokens = sourcePinActivation.takeTokens();
565+
ValueList values = new ValueList();
566+
for (int j = 0; j < tokens.size(); j++) {
567+
Token token = tokens.getValue(j);
568+
values.addValue(token.getValue());
569+
}
570+
571+
this.putTokens(targetPin, values);
572+
}
573+
}
574+
575+
} // ActionActivation

org.modeldriven.fuml/src/main/java/fuml/semantics/actions/CallActionActivation.java

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
* Initial version copyright 2008 Lockheed Martin Corporation, except
44
* as stated in the file entitled Licensing-Information.
55
*
6-
* All modifications copyright 2009-2012 Data Access Technologies, Inc.
6+
* Modifications:
7+
* Copyright 2009-2012 Data Access Technologies, Inc.
8+
* Copyright 2020 Model Driven Solutions, Inc.
9+
* Copyright 2020 CEA LIST.
710
*
811
* Licensed under the Academic Free License version 3.0
912
* (http://www.opensource.org/licenses/afl-3.0.php), except as stated
@@ -31,9 +34,11 @@ public abstract class CallActionActivation extends
3134
public void doAction() {
3235
// Get the call execution object, set its input parameters from the
3336
// argument pins and execute it.
34-
// Once execution completes, copy the values of the output parameters of
35-
// the call execution to the result pins of the call action execution,
36-
// then destroy the execution.
37+
// Once execution completes, if the execution raised an exception, then
38+
// propagate the exception.
39+
// Otherwise, copy the values of the output parameters of the call execution
40+
// to the result pins of the call action execution.
41+
// In either case, destroy the execution.
3742

3843
Execution callExecution = this.getCallExecution();
3944

@@ -63,30 +68,34 @@ public void doAction() {
6368
}
6469

6570
callExecution.execute();
66-
67-
ParameterValueList outputParameterValues = callExecution
68-
.getOutputParameterValues();
69-
70-
pinNumber = 1;
71-
i = 1;
72-
while (i <= parameters.size()) {
73-
Parameter parameter = parameters.getValue(i - 1);
74-
if ((parameter.direction == ParameterDirectionKind.inout)
75-
| (parameter.direction == ParameterDirectionKind.out)
76-
| (parameter.direction == ParameterDirectionKind.return_)) {
77-
for (int j = 0; j < outputParameterValues.size(); j++) {
78-
ParameterValue outputParameterValue = outputParameterValues
79-
.getValue(j);
80-
if (outputParameterValue.parameter == parameter) {
81-
OutputPin resultPin = resultPins
82-
.getValue(pinNumber - 1);
83-
this.putTokens(resultPin,
84-
outputParameterValue.values);
71+
72+
if(callExecution.exception != null) {
73+
this.propagateException(callExecution.exception);
74+
} else {
75+
ParameterValueList outputParameterValues = callExecution
76+
.getOutputParameterValues();
77+
78+
pinNumber = 1;
79+
i = 1;
80+
while (i <= parameters.size()) {
81+
Parameter parameter = parameters.getValue(i - 1);
82+
if ((parameter.direction == ParameterDirectionKind.inout)
83+
| (parameter.direction == ParameterDirectionKind.out)
84+
| (parameter.direction == ParameterDirectionKind.return_)) {
85+
for (int j = 0; j < outputParameterValues.size(); j++) {
86+
ParameterValue outputParameterValue = outputParameterValues
87+
.getValue(j);
88+
if (outputParameterValue.parameter == parameter) {
89+
OutputPin resultPin = resultPins
90+
.getValue(pinNumber - 1);
91+
this.putTokens(resultPin,
92+
outputParameterValue.values);
93+
}
8594
}
95+
pinNumber = pinNumber + 1;
8696
}
87-
pinNumber = pinNumber + 1;
97+
i = i + 1;
8898
}
89-
i = i + 1;
9099
}
91100

92101
callExecution.destroy();
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2020 Model Driven Solutions, Inc.
3+
* Copyright 2020 CEA LIST.
4+
*
5+
* Licensed under the Academic Free License version 3.0
6+
* (http://www.opensource.org/licenses/afl-3.0.php), except as stated
7+
* in the file entitled Licensing-Information.
8+
*/
9+
10+
package fuml.semantics.actions;
11+
12+
import fuml.Debug;
13+
import fuml.semantics.values.Value;
14+
import fuml.syntax.actions.RaiseExceptionAction;
15+
16+
public class RaiseExceptionActionActivation extends ActionActivation {
17+
18+
@Override
19+
public void doAction() {
20+
// Get the value on the exception pin and propagate it as an exception.
21+
22+
RaiseExceptionAction action = (RaiseExceptionAction)this.node;
23+
Value exception = this.takeTokens(action.exception).getValue(0);
24+
25+
Debug.println("[doAction] action = " + action.name + ", exception = " + exception);
26+
27+
this.propagateException(exception);
28+
}
29+
30+
}

0 commit comments

Comments
 (0)