Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-08-05 08:57:42 -0400
committerHenrik Rentz-Reichert2013-08-05 08:57:42 -0400
commitb2981b856cf7eaf8311ef473b7eef1380538d53b (patch)
tree77ecafc79b342a78970e9a8e7738385dd1040aad /runtime/org.eclipse.etrice.runtime.java/src/org/eclipse
parent656d38a620ad323d3a96003acac7bbb49fe7f29d (diff)
downloadorg.eclipse.etrice-b2981b856cf7eaf8311ef473b7eef1380538d53b.tar.gz
org.eclipse.etrice-b2981b856cf7eaf8311ef473b7eef1380538d53b.tar.xz
org.eclipse.etrice-b2981b856cf7eaf8311ef473b7eef1380538d53b.zip
[runtime.java] bug fix for DynamicActorTest7
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.java/src/org/eclipse')
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBroker.java72
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/OptionalActorInterfaceBase.java36
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedOptionalActorInterfaceBase.java2
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ScalarOptionalActorInterfaceBase.java2
4 files changed, 78 insertions, 34 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBroker.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBroker.java
index 5b6187578..9175b304f 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBroker.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBroker.java
@@ -37,7 +37,10 @@ import org.eclipse.etrice.runtime.java.messaging.Message;
*/
public class InterfaceItemBroker extends InterfaceItemBase implements IInterfaceItemBroker {
+ // CAUTION: must NOT initialize firstPeer with null since is set in base class constructor and
+ // AFTERWARDS initialized ==> value is lost
private IRTObject firstPeer;
+ private InterfaceItemBase secondPeer;
public InterfaceItemBroker(IInterfaceItemOwner parent, String name, int localId) {
this(parent, name, localId, 0);
@@ -69,18 +72,11 @@ public class InterfaceItemBroker extends InterfaceItemBase implements IInterface
if (peerPaths!=null && !peerPaths.isEmpty()) {
firstPeer = getObject(peerPaths.get(0));
if (firstPeer instanceof InterfaceItemBroker) {
- firstPeer = ((InterfaceItemBroker) firstPeer).connectWith(this);
+ if (((InterfaceItemBroker) firstPeer).firstPeer==null)
+ ((InterfaceItemBroker) firstPeer).firstPeer = this;
}
}
}
-
- @Override
- public String getInstancePath(char delim) {
- if (getParent() instanceof OptionalActorInterfaceBase)
- return ((OptionalActorInterfaceBase)getParent()).getInterfaceInstancePath()+PATH_DELIM+getName();
-
- return super.getInstancePath(delim);
- }
/* (non-Javadoc)
* @see org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase#connectWith(org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase)
@@ -90,15 +86,50 @@ public class InterfaceItemBroker extends InterfaceItemBase implements IInterface
if (firstPeer!=null) {
// we are already connected, lets connect our new peer with the previous one
+ secondPeer = peer;
+
+ // we don't want to change firstPeer, so make a copy
+ IRTObject first = firstPeer;
+
+ {
+ InterfaceItemBroker broker = this;
+ while (true) {
+ if (broker.firstPeer instanceof InterfaceItemBroker) {
+ InterfaceItemBroker neighbor = (InterfaceItemBroker) broker.firstPeer;
+ if (neighbor.firstPeer==broker) {
+ // neighbor points back
+ if (neighbor.secondPeer!=null) {
+ first = neighbor.secondPeer;
+ break;
+ }
+ else {
+ // we can't connect all the way to the final peer: deposit peer and wait for other side being ready
+ broker.secondPeer = peer;
+ return this;
+ }
+ }
+ broker = neighbor;
+ }
+ else {
+ first = broker.firstPeer;
+ break;
+ }
+ }
+ }
+
InterfaceItemBase peer1 = null;
InterfaceItemBase peer2 = peer;
- // get a new replicated sub port if appropriate
- if (firstPeer instanceof IReplicatedInterfaceItem) {
- peer1 = ((IReplicatedInterfaceItem) firstPeer).createSubInterfaceItem();
+ if (first instanceof IReplicatedInterfaceItem) {
+ // get a new replicated sub port
+ peer1 = ((IReplicatedInterfaceItem) first).createSubInterfaceItem();
+ }
+ else if (first instanceof InterfaceItemBase) {
+ peer1 = (InterfaceItemBase) first;
}
- else if (firstPeer instanceof InterfaceItemBase) {
- peer1 = (InterfaceItemBase) firstPeer;
+ else {
+ assert(false): "unexpected peer kind";
+ return null;
}
peer2.peerAddress = peer1.getAddress();
@@ -108,8 +139,19 @@ public class InterfaceItemBroker extends InterfaceItemBase implements IInterface
return peer1;
}
+ else {
+ firstPeer = peer;
- return null;
+ return this;
+ }
+ }
+
+ @Override
+ public String getInstancePath(char delim) {
+ if (getParent() instanceof OptionalActorInterfaceBase)
+ return ((OptionalActorInterfaceBase)getParent()).getInterfaceInstancePath()+PATH_DELIM+getName();
+
+ return super.getInstancePath(delim);
}
@Override
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/OptionalActorInterfaceBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/OptionalActorInterfaceBase.java
index bd72a1239..dfa9362a5 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/OptionalActorInterfaceBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/OptionalActorInterfaceBase.java
@@ -133,23 +133,25 @@ public abstract class OptionalActorInterfaceBase extends SystemPortOwner impleme
*/
@Override
public IRTObject getObject(String path) {
- int sep = path.indexOf(PATH_DELIM, parentPath.length()+1);
- if (sep>=0 && sep<path.length()) {
- // we turn the path into a relative one and resolve it starting at this instance
-
- // path segment of the optional actor
- String optInst = path.substring(parentPath.length(), sep);
-
- // remainder
- path = path.substring(sep);
-
- // if remainder only contains >1 segment
- if (path.indexOf(PATH_DELIM, 1)>=0)
- // we add the optional actor segment
- path = optInst+path;
-
- // finally we have to prefix with our own name since the relative path has to start with that
- path = getName()+path;
+ if (path.startsWith(ownPath)) {
+ int sep = path.indexOf(PATH_DELIM, parentPath.length()+1);
+ if (sep>=0 && sep<path.length()) {
+ // we turn the path into a relative one and resolve it starting at this instance
+
+ // path segment of the optional actor
+ String optInst = path.substring(parentPath.length(), sep);
+
+ // remainder
+ path = path.substring(sep);
+
+ // if remainder only contains >1 segment
+ if (path.indexOf(PATH_DELIM, 1)>=0)
+ // we add the optional actor segment
+ path = optInst+path;
+
+ // finally we have to prefix with our own name since the relative path has to start with that
+ path = getName()+path;
+ }
}
return super.getObject(path);
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedOptionalActorInterfaceBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedOptionalActorInterfaceBase.java
index 3cedc7a4b..68900184f 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedOptionalActorInterfaceBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedOptionalActorInterfaceBase.java
@@ -177,7 +177,7 @@ public class ReplicatedOptionalActorInterfaceBase extends OptionalActorInterface
}
public String toString(){
- return "ReplicatedOptionalActorInterface(className="+getClassName()+", instancePath="+getInstancePath()+")";
+ return "ReplicatedOptionalActorInterface(className="+getClassName()+", instancePath="+getInterfaceInstancePath()+")";
}
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ScalarOptionalActorInterfaceBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ScalarOptionalActorInterfaceBase.java
index 6afdc5ec0..dfd6263be 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ScalarOptionalActorInterfaceBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ScalarOptionalActorInterfaceBase.java
@@ -115,7 +115,7 @@ public class ScalarOptionalActorInterfaceBase extends OptionalActorInterfaceBase
}
public String toString(){
- return "ScalarOptionalActorInterface(className="+getClassName()+", instancePath="+getInstancePath()+")";
+ return "ScalarOptionalActorInterface(className="+getClassName()+", instancePath="+getInterfaceInstancePath()+")";
}
}

Back to the top