Skip to content

Commit 4acc136

Browse files
committed
Added operations to CallEventExecution (OMG issue FUML13-16)
- Also renamed CallEventOccurrence::releaseCaller to returnFromCall.
1 parent c74f53a commit 4acc136

5 files changed

Lines changed: 53 additions & 31 deletions

File tree

org.modeldriven.fuml/src/main/java/fUML/Semantics/Actions/CompleteActions/ReturnInformation.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void reply(ParameterValueList outputParameterValues) {
3131
// releasing the caller.
3232

3333
this.callEventOccurrence.setOutputParameterValues(outputParameterValues);
34-
this.callEventOccurrence.releaseCaller();
34+
this.callEventOccurrence.returnFromCall();
3535
}
3636

3737
@Override
@@ -84,7 +84,12 @@ public Value copy() {
8484
public String toString() {
8585
// Return a string representation of the return information.
8686

87-
return "ReturnInformation(" + callEventOccurrence.getOperation().name + ")";
87+
String s = "ReturnInformation";
88+
String name = callEventOccurrence.getOperation().name;
89+
if (name != null) {
90+
s = s + "(" + name + ")";
91+
}
92+
return s;
8893
}
8994

9095
}

org.modeldriven.fuml/src/main/java/fUML/Semantics/CommonBehaviors/Communications/CallEventBehavior.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ public void setOperation(Operation operation) {
4343
this.member.addValue(parameter);
4444
this.ownedParameter.addValue(parameter);
4545
}
46-
this.isReentrant = true;
46+
this.isReentrant = true;
47+
this.name = "CallEventBehavior";
48+
if (operation.name != null) {
49+
this.name = this.name + "(" + operation.name + ")";
50+
}
4751
}
4852

4953
}

org.modeldriven.fuml/src/main/java/fUML/Semantics/CommonBehaviors/Communications/CallEventExecution.java

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
package fUML.Semantics.CommonBehaviors.Communications;
1010

1111
import fUML.Debug;
12-
import fUML.Semantics.Classes.Kernel.Object_;
1312
import fUML.Semantics.Classes.Kernel.Reference;
1413
import fUML.Semantics.Classes.Kernel.Value;
1514
import fUML.Semantics.CommonBehaviors.BasicBehaviors.Execution;
@@ -22,7 +21,6 @@
2221

2322
public class CallEventExecution extends Execution {
2423

25-
public Object_ caller = null;
2624
public boolean callerSuspended = false;
2725

2826
public boolean isCallerSuspended() {
@@ -49,33 +47,54 @@ public void setCallerSuspended(boolean callerSuspended) {
4947
_endIsolation();
5048
}
5149

52-
public void suspend(){
50+
public void suspendCaller() {
5351
// Suspend the caller until the caller is released.
5452

55-
this.setCallerSuspended(true);
56-
57-
do {
53+
while(this.isCallerSuspended()) {
5854
this.wait_();
59-
} while(this.isCallerSuspended());
55+
}
56+
57+
}
58+
59+
public void releaseCaller() {
60+
// Release the caller, if suspended.
6061

62+
this.setCallerSuspended(false);
6163
}
6264

6365
@Override
6466
public void execute() {
65-
// Send a new CallEventOccurrence to the target of this call
66-
// (which is the context of this execution) and suspend the
67-
// caller until the call is completed. Note that the
68-
// call will never be completed if the target is not an active
69-
// object, since then the object would then have no event
70-
// pool in which the event occurrence could be placed.
67+
// Make the call on the target object (which is the context of this execution)
68+
// and suspend the caller until the call is completed.
69+
70+
// Note: The callerSuspended flag needs to be set before the call is made,
71+
// in case the call is immediately handled and returned, even before the
72+
// suspend loop is started.
73+
this.setCallerSuspended(true);
74+
75+
this.makeCall();
76+
this.suspendCaller();
77+
}
78+
79+
public void makeCall() {
80+
// Make the call on the target object (which is the context of this execution)
81+
// by sending a call event occurrence. (Note that the call will never be
82+
// completed if the target is not an active object, since then the object
83+
// would then have no event pool in which the event occurrence could be placed.)
7184

7285
Reference reference = new Reference();
73-
reference.referent = this.context;
74-
86+
reference.referent = this.context;
87+
this.createEventOccurrence().sendTo(reference);
88+
}
89+
90+
public EventOccurrence createEventOccurrence() {
91+
// Create a call event occurrence associated with this call event execution.
92+
// (This operation may be overridden in subclasses to alter how the event
93+
// occurrence is create, e.g., if it is necessary to wrap it.)
94+
7595
CallEventOccurrence eventOccurrence = new CallEventOccurrence();
7696
eventOccurrence.execution = this;
77-
eventOccurrence.sendTo(reference);
78-
this.suspend();
97+
return eventOccurrence;
7998
}
8099

81100
public Operation getOperation() {

org.modeldriven.fuml/src/main/java/fUML/Semantics/CommonBehaviors/Communications/CallEventOccurrence.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,21 @@ public ParameterValueList getParameterValues() {
4343
// this call event occurrence, which correspond to the values of the
4444
// operation input parameters for the call.
4545

46-
ParameterValueList parameterValues = new ParameterValueList();
47-
if (this.execution != null) {
48-
parameterValues = this.execution.getInputParameterValues();
49-
}
50-
return parameterValues;
46+
return this.execution.getInputParameterValues();
5147
}
5248

5349
public void setOutputParameterValues(ParameterValueList parameterValues) {
5450
// Set the output parameter values of the call event execution for
5551
// this call event occurrence, which correspond to the values of the
5652
// operation output parameters for the call.
5753

58-
if (this.execution != null) {
59-
this.execution.setOutputParameterValues(parameterValues);
60-
}
54+
this.execution.setOutputParameterValues(parameterValues);
6155
}
6256

63-
public void releaseCaller() {
57+
public void returnFromCall() {
6458
// Release the caller on return from the call.
6559

66-
this.execution.setCallerSuspended(false);
60+
this.execution.releaseCaller();
6761
}
6862

6963
}

org.modeldriven.fuml/src/test/java/org/modeldriven/fuml/test/builtin/environment/ActivityFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1814,7 +1814,7 @@ public void createCallSender(String operationName, String signalName) {
18141814
NamedElement element = this.environment.getElement(signalName);
18151815

18161816
if (element == null || !(element instanceof Signal)) {
1817-
Debug.println("[createSender] " + signalName
1817+
Debug.println("[createCallSender] " + signalName
18181818
+ " does not exist or is not a signal.");
18191819
return;
18201820
}

0 commit comments

Comments
 (0)