Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-10-01 10:00:54 -0400
committerHenrik Rentz-Reichert2013-10-01 12:58:33 -0400
commite9271e02c6b65a99b7feb77eaddcf6898344e568 (patch)
tree9988ae18e99a920de5240de76268705adb6d10c6 /runtime/org.eclipse.etrice.runtime.java/src/org/eclipse
parent5507edae78655799c3a4f754d6f10fec6a9a9b02 (diff)
downloadorg.eclipse.etrice-e9271e02c6b65a99b7feb77eaddcf6898344e568.tar.gz
org.eclipse.etrice-e9271e02c6b65a99b7feb77eaddcf6898344e568.tar.xz
org.eclipse.etrice-e9271e02c6b65a99b7feb77eaddcf6898344e568.zip
[runtime.java][generator.java] Bug 418424: nest runtime binding creation as deep as possible
https://bugs.eclipse.org/418424 Change-Id: I398011365c22fcc4d57ef8768cf3992911364e77
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/messaging/IRTObject.java61
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTObject.java13
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataPortBase.java10
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataReceivePort.java8
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataSendPort.java11
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IInterfaceItem.java8
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IInterfaceItemBroker.java5
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IReplicatedInterfaceItem.java2
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBase.java55
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBroker.java60
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/OptionalActorInterfaceBase.java149
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PathToPeers.java53
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedInterfaceItemBase.java27
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java41
14 files changed, 131 insertions, 372 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/IRTObject.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/IRTObject.java
index 42d95caba..63ff03668 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/IRTObject.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/IRTObject.java
@@ -15,28 +15,85 @@ package org.eclipse.etrice.runtime.java.messaging;
import java.util.List;
/**
- * The runtime object interface
+ * The runtime object interface for all runtime objects. Those objects form a tree with a single root.
+ * Since each object has a name it also has a unique path in the tree.
+ *
* @author Thomas Schuetz
* @author Henrik Rentz-Reichert
*
*/
+/**
+ * @author hrentz
+ *
+ */
public interface IRTObject {
+ /**
+ * The delimiter character for path segments.
+ */
static final char PATH_DELIM = '/';
+
+ /**
+ * The delimiter character for path segments when the path should be used as name.
+ */
static final char PATHNAME_DELIM = '_';
+
+ /**
+ * An empty name.
+ */
static final String NO_NAME = "<no name>";
+ /**
+ * @return the name of the object (has to be unique among siblings)
+ */
String getName();
+
+ /**
+ * @return a list of all child objects
+ */
List<IRTObject> getChildren();
+
+ /**
+ * @return the parent object in the instance tree
+ */
IRTObject getParent();
+
+ /**
+ * @return the root object of the tree (that has no parent)
+ */
IRTObject getRoot();
+
+ /**
+ * @param name the name of a child
+ * @return the child with the given name or {@code null} if not found
+ */
IRTObject getChild(String name);
+
+ /**
+ * @param path a path with segments delimited by {@link #PATH_DELIM}. It can be relative or absolute.
+ * @return the object with this instance path or {@code null}
+ */
IRTObject getObject(String path);
+ /**
+ * @param delim a delimiter character
+ * @return the path with segments delimited by the given character
+ */
String getInstancePath(char delim);
+
+ /**
+ * @return the absolute instance path of this object using {@link #PATH_DELIM}
+ */
String getInstancePath();
+
+ /**
+ * @return the absolute instance path of this object using {@link #PATHNAME_DELIM}
+ */
String getInstancePathName();
+ /**
+ * @param path an absolute path
+ * @return the thread to which this path is mapped (used to query this path from the parent object or from the sub system)
+ */
int getThreadForPath(String path);
- List<String> getPeersForPath(String path);
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTObject.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTObject.java
index e10425759..39705aeb1 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTObject.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTObject.java
@@ -9,7 +9,6 @@
package org.eclipse.etrice.runtime.java.messaging;
import java.util.ArrayList;
-import java.util.List;
/**
* An implementation of the IRTObject interface using a hierarchical structure
@@ -89,7 +88,7 @@ public class RTObject implements IRTObject {
String first = segments[0];
for (String segment : segments) {
- if (segment==first) {
+ if (isAbsolute && segment==first) {
if (!segment.equals(current.getName()))
return null;
}
@@ -131,16 +130,6 @@ public class RTObject implements IRTObject {
return parent.getThreadForPath(path);
return -1;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.etrice.runtime.java.messaging.IRTObject#getPeersForPath(java.lang.String)
- */
- @Override
- public List<String> getPeersForPath(String path) {
- if (parent!=null)
- return parent.getPeersForPath(path);
- return null;
- }
private String toStringRecursive(String indent) {
StringBuilder result = new StringBuilder(indent+toString()+"\n");
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataPortBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataPortBase.java
index ba5d575e7..48d1df033 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataPortBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataPortBase.java
@@ -35,4 +35,14 @@ public class DataPortBase extends RTObject {
return localId;
}
+ public static void connect(IRTObject obj, String path1, String path2) {
+ IRTObject obj1 = obj.getObject(path1);
+ IRTObject obj2 = obj.getObject(path2);
+ if (obj1 instanceof DataSendPort && obj2 instanceof DataReceivePort) {
+ ((DataReceivePort)obj2).connect((DataSendPort) obj1);
+ }
+ else if (obj2 instanceof DataSendPort && obj1 instanceof DataReceivePort) {
+ ((DataReceivePort)obj1).connect((DataSendPort) obj2);
+ }
+ }
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataReceivePort.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataReceivePort.java
index f35b70c4a..d365b5a4f 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataReceivePort.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataReceivePort.java
@@ -12,8 +12,6 @@
package org.eclipse.etrice.runtime.java.modelbase;
-import java.util.List;
-
import org.eclipse.etrice.runtime.java.messaging.IRTObject;
/**
@@ -28,12 +26,6 @@ public abstract class DataReceivePort extends DataPortBase {
*/
protected DataReceivePort(IRTObject parent, String name, int localId) {
super(parent, name, localId);
-
- List<String> peerPaths = getParent().getPeersForPath(getInstancePath());
- if (peerPaths!=null && !peerPaths.isEmpty()) {
- IRTObject object = getObject(peerPaths.get(0));
- connect((DataSendPort) object);
- }
}
/**
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataSendPort.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataSendPort.java
index 189a441cd..4852f91b5 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataSendPort.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/DataSendPort.java
@@ -12,8 +12,6 @@
package org.eclipse.etrice.runtime.java.modelbase;
-import java.util.List;
-
import org.eclipse.etrice.runtime.java.messaging.IRTObject;
/**
@@ -24,14 +22,5 @@ public class DataSendPort extends DataPortBase {
public DataSendPort(IRTObject parent, String name, int localId) {
super(parent, name, localId);
-
- List<String> peerPaths = getParent().getPeersForPath(getInstancePath());
- if (peerPaths!=null) {
- for (String peerPath : peerPaths) {
- IRTObject object = getObject(peerPath);
- if (object instanceof DataReceivePort)
- ((DataReceivePort)object).connect(this);
- }
- }
}
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IInterfaceItem.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IInterfaceItem.java
new file mode 100644
index 000000000..851cca755
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IInterfaceItem.java
@@ -0,0 +1,8 @@
+package org.eclipse.etrice.runtime.java.modelbase;
+
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+
+public interface IInterfaceItem extends IRTObject {
+
+ IInterfaceItem connectWith(IInterfaceItem peer);
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IInterfaceItemBroker.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IInterfaceItemBroker.java
index d8b4dbb09..996b0f3eb 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IInterfaceItemBroker.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IInterfaceItemBroker.java
@@ -12,6 +12,7 @@
package org.eclipse.etrice.runtime.java.modelbase;
+
/**
* This is just a marker interface.
*
@@ -19,6 +20,6 @@ package org.eclipse.etrice.runtime.java.modelbase;
* @author Henrik Rentz-Reichert
*
*/
-public interface IInterfaceItemBroker {
-
+public interface IInterfaceItemBroker extends IInterfaceItem {
+
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IReplicatedInterfaceItem.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IReplicatedInterfaceItem.java
index 0899f67bc..ad0ee3eac 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IReplicatedInterfaceItem.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IReplicatedInterfaceItem.java
@@ -16,7 +16,7 @@ package org.eclipse.etrice.runtime.java.modelbase;
* @author Henrik Rentz-Reichert
*
*/
-public interface IReplicatedInterfaceItem {
+public interface IReplicatedInterfaceItem extends IInterfaceItem {
InterfaceItemBase createSubInterfaceItem();
void removeItem(InterfaceItemBase item);
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBase.java
index b05d3b820..df4441621 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/InterfaceItemBase.java
@@ -8,8 +8,6 @@
package org.eclipse.etrice.runtime.java.modelbase;
-import java.util.List;
-
import org.eclipse.etrice.runtime.java.messaging.AbstractMessageReceiver;
import org.eclipse.etrice.runtime.java.messaging.Address;
import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
@@ -23,7 +21,7 @@ import org.eclipse.etrice.runtime.java.messaging.RTServices;
*
* @author Henrik Rentz-Reichert
*/
-public abstract class InterfaceItemBase extends AbstractMessageReceiver {
+public abstract class InterfaceItemBase extends AbstractMessageReceiver implements IInterfaceItem {
/**
* If this is part of an {@link IReplicatedInterfaceItem} then the
@@ -38,7 +36,7 @@ public abstract class InterfaceItemBase extends AbstractMessageReceiver {
private int localId;
private int idx;
protected Address peerAddress = null;
- private InterfaceItemBase peer;
+ private IInterfaceItem peer;
/**
@@ -67,27 +65,9 @@ public abstract class InterfaceItemBase extends AbstractMessageReceiver {
this.ownMsgReceiver = msgSvc;
}
-
- if (replicator==null)
- connectWithPeer();
- }
-
- protected void connectWithPeer() {
- List<String> peerPaths = getParent().getPeersForPath(getInstancePath());
- if (peerPaths!=null && !peerPaths.isEmpty()) {
- IRTObject object = getObject(peerPaths.get(0));
- InterfaceItemBase peer = null;
- if (object instanceof InterfaceItemBase) {
- peer = ((InterfaceItemBase) object);
- }
- else if (object instanceof IReplicatedInterfaceItem) {
- peer = ((IReplicatedInterfaceItem) object).createSubInterfaceItem();
- }
- connectWith(peer);
- }
}
- protected synchronized InterfaceItemBase connectWith(InterfaceItemBase peer) {
+ public synchronized IInterfaceItem connectWith(IInterfaceItem peer) {
if (peer!=null) {
this.peer = peer;
@@ -96,11 +76,18 @@ public abstract class InterfaceItemBase extends AbstractMessageReceiver {
return this.peer;
}
- // connect with each other
- peerAddress = peer.getAddress();
- peer.peerAddress = getAddress();
- this.peerMsgReceiver = peer.ownMsgReceiver;
- peer.peerMsgReceiver = ownMsgReceiver;
+ if (peer instanceof IReplicatedInterfaceItem)
+ peer = ((IReplicatedInterfaceItem) peer).createSubInterfaceItem();
+
+ if (peer instanceof InterfaceItemBase) {
+ InterfaceItemBase thePeer = (InterfaceItemBase) peer;
+
+ // connect with each other
+ peerAddress = thePeer.getAddress();
+ thePeer.peerAddress = getAddress();
+ this.peerMsgReceiver = thePeer.ownMsgReceiver;
+ thePeer.peerMsgReceiver = ownMsgReceiver;
+ }
}
@@ -110,7 +97,8 @@ public abstract class InterfaceItemBase extends AbstractMessageReceiver {
protected synchronized void disconnect() {
disconnectInternal();
if (peer!=null) {
- peer.disconnectInternal();
+ if (peer instanceof InterfaceItemBase)
+ ((InterfaceItemBase)peer).disconnectInternal();
peer = null;
}
}
@@ -170,4 +158,13 @@ public abstract class InterfaceItemBase extends AbstractMessageReceiver {
public String toString() {
return ((replicator!=null)?"sub ":"")+"port "+getName()+" "+getAddress()+" <-> "+getPeerAddress();
}
+
+ public static void connect(IRTObject obj, String path1, String path2) {
+ IRTObject obj1 = obj.getObject(path1);
+ IRTObject obj2 = obj.getObject(path2);
+
+ if (obj1 instanceof IInterfaceItem && obj2 instanceof IInterfaceItem) {
+ ((IInterfaceItem)obj1).connectWith((IInterfaceItem) obj2);
+ }
+ }
}
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 ba9be9804..70d2a2bf1 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
@@ -12,9 +12,6 @@
package org.eclipse.etrice.runtime.java.modelbase;
-import java.util.List;
-
-import org.eclipse.etrice.runtime.java.messaging.IRTObject;
import org.eclipse.etrice.runtime.java.messaging.Message;
/**
@@ -39,8 +36,8 @@ public class InterfaceItemBroker extends InterfaceItemBase implements IInterface
// 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;
+ private IInterfaceItem firstPeer;
+ private IInterfaceItem secondPeer;
public InterfaceItemBroker(IInterfaceItemOwner parent, String name, int localId) {
this(parent, name, localId, 0);
@@ -63,33 +60,19 @@ public class InterfaceItemBroker extends InterfaceItemBase implements IInterface
public void receive(Message msg) {
// ignore this, will never receive a message
}
-
- /* (non-Javadoc)
- * @see org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase#connectWithPeer()
- */
- protected void connectWithPeer() {
- List<String> peerPaths = getParent().getPeersForPath(getInstancePath());
- if (peerPaths!=null && !peerPaths.isEmpty()) {
- firstPeer = getObject(peerPaths.get(0));
- if (firstPeer instanceof InterfaceItemBroker) {
- if (((InterfaceItemBroker) firstPeer).firstPeer==null)
- ((InterfaceItemBroker) firstPeer).firstPeer = this;
- }
- }
- }
-
+
/* (non-Javadoc)
* @see org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase#connectWith(org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase)
*/
@Override
- public InterfaceItemBase connectWith(InterfaceItemBase peer) {
+ public IInterfaceItem connectWith(IInterfaceItem peer) {
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;
+ IInterfaceItem first = firstPeer;
{
InterfaceItemBroker broker = this;
@@ -117,30 +100,18 @@ public class InterfaceItemBroker extends InterfaceItemBase implements IInterface
}
}
- InterfaceItemBase peer1 = null;
- InterfaceItemBase peer2 = peer;
-
- if (first instanceof IReplicatedInterfaceItem) {
- // get a new replicated sub port
- peer1 = ((IReplicatedInterfaceItem) first).createSubInterfaceItem();
- }
- else if (first instanceof InterfaceItemBase) {
- peer1 = (InterfaceItemBase) first;
- }
- else {
- assert(false): "unexpected peer kind";
- return null;
- }
-
- peer2.peerAddress = peer1.getAddress();
- peer2.peerMsgReceiver = peer1.ownMsgReceiver;
- peer1.peerAddress = peer2.getAddress();
- peer1.peerMsgReceiver = peer2.ownMsgReceiver;
-
- return peer1;
+ return first.connectWith(peer);
}
else {
firstPeer = peer;
+
+ if (firstPeer instanceof InterfaceItemBroker) {
+ // deal with the situation that two brokers aren't connected yet: make symmetrical and set also first peer
+ // of neighbor
+ InterfaceItemBroker neighbor = (InterfaceItemBroker) firstPeer;
+ if (neighbor.firstPeer==null)
+ neighbor.firstPeer = this;
+ }
return this;
}
@@ -158,7 +129,8 @@ public class InterfaceItemBroker extends InterfaceItemBase implements IInterface
public String toString() {
String peer1 = (firstPeer instanceof InterfaceItemBase)? (((InterfaceItemBase)firstPeer).getAddress().toString()+"("+firstPeer.getClass().toString()+")")
:(firstPeer instanceof ReplicatedInterfaceItemBase? (((ReplicatedInterfaceItemBase)firstPeer).toString()+"("+firstPeer.getClass().toString()+")"):"null");
- String peer2 = secondPeer==null? "null":(secondPeer.getAddress().toString()+"("+secondPeer.getClass().toString()+")");
+ String peer2 = (secondPeer instanceof InterfaceItemBase)? (((InterfaceItemBase)secondPeer).getAddress().toString()+"("+secondPeer.getClass().toString()+")")
+ :(secondPeer instanceof ReplicatedInterfaceItemBase? (((ReplicatedInterfaceItemBase)secondPeer).toString()+"("+secondPeer.getClass().toString()+")"):"null");
return "interface broker port "+getName()+" - 1. peer "+peer1+" 2. peer "+peer2;
}
}
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 dee0487b1..7ad1d4e6b 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
@@ -15,9 +15,6 @@ package org.eclipse.etrice.runtime.java.modelbase;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
import org.eclipse.etrice.runtime.java.messaging.IRTObject;
import org.eclipse.etrice.runtime.java.modelbase.RTSystemProtocol.RTSystemConjPort;
@@ -58,25 +55,6 @@ public abstract class OptionalActorInterfaceBase extends SystemPortOwner impleme
private String className;
/**
- * This map is set during optional actor creation by the factory.
- */
- private PathToPeers path2peers = null;
-
- /**
- * The path of this instance is used to determine correct mappings.
- * It is subtracted from incoming paths, then (relative) peer paths are looked up and
- * the result paths are turned into absolute ones by adding this again.
- *
- * @see #getPeersForPath(String)
- */
- private String parentPath;
-
- /**
- * This is equivalent to {@link #parentPath}+{@link #getName()}
- */
- private String ownPath;
-
- /**
* The thread (associated with the message service of this ID) that will be used by the
* optional actor instance.
*/
@@ -98,8 +76,6 @@ public abstract class OptionalActorInterfaceBase extends SystemPortOwner impleme
super(parent, name);
className = clsname;
subtreeThread = parent.getThread();
- parentPath = getInstancePath();
- ownPath = getInterfaceInstancePath();
RTSystemPort = new RTSystemConjPort(this, IFITEM_RTSystemPort);
}
@@ -123,112 +99,7 @@ public abstract class OptionalActorInterfaceBase extends SystemPortOwner impleme
public String getInterfaceInstancePath() {
return super.getInstancePath(PATH_DELIM);
}
-
- /**
- * If the path points to our <i>interior</i> (which should be always the case)
- * the we turn it into a relative one starting here.
- * It is important that our own interface item brokers are treated specially.
- *
- * @see org.eclipse.etrice.runtime.java.messaging.RTObject#getObject(java.lang.String)
- */
- @Override
- public IRTObject getObject(String 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 contains more than one segment it points into the optional actor
- if (path.indexOf(PATH_DELIM, 1)>=0)
- // we add the optional actor segment
- path = optInst+path;
- else {
- /* the port is our own port
- * a) on the interface ==> it is a broker and direct child
- * b) internal ==> it is a child of the optional actor
- */
- IRTObject obj = super.getObject(getName()+path);
- if (obj==null) {
- obj = super.getObject(getName()+optInst+path);
- }
- return obj;
- }
-
- // 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);
- }
-
- /**
- * Get list of peer paths.
- * <p>
- * This method delegates to its parent if {@link #getPath2peers()}{@code ==null}.
- * </p>
- * <p>
- * If an optional actor instance is created the used factory will set
- * its own path-to-peer mapping. Then the incoming path is made relative to
- * the created actor and the paths looked up in the map are made absolute again.
- *
- * @param path an absolute path
- * @return a list of absolute peer paths or {@code null} if not mapped
- */
- @Override
- public List<String> getPeersForPath(String path) {
- // if no mapping available we delegate to our parent (which is never null)
- if (getPath2peers()==null)
- return getParent().getPeersForPath(path);
-
- /* remove parent path+1 up to next delimiter (thus including the optional ref name)
- * e.g.
- * incoming path = /LS/appl/cont/opt/path/to/port
- * rel path = /path/to/port
- * result of lookup (to interface port) = /port
- * returned = /LS/appl/cont/opt/port (one of the interface port brokers)
- */
- int sep = path.indexOf(PATH_DELIM, parentPath.length()+1);
- if (sep<0 || sep>=path.length())
- return null;
-
- /* The optInstPath for scalar optional actors is parentPath/<name>.
- * However, for replicated actors it is parentPath/<name>:<idx>
- */
- String optInstPath = path.substring(0, sep);
- path = path.substring(sep);
-
- if (path.indexOf('/', 1)<0) {
- /*
- * This is an end port on the interface.
- * It is directly mapped to its broker (there is no mapping for it)
- */
- return Collections.singletonList(ownPath+path);
- }
-
- ArrayList<String> paths = getPath2peers().get(path);
- if (paths!=null) {
- ArrayList<String> result = new ArrayList<String>();
- for (String p : paths) {
- if (p.indexOf('/', 1)>=0)
- // it's a path nested in the optional instance
- p = optInstPath+p;
- else
- // its a path to one of my brokers (an immediate child)
- p = ownPath+p;
- result.add(p);
- }
- return result;
- }
- return paths;
- }
-
+
/**
* Get thread for path. The thread is passed to the optional actor creation method.
*
@@ -241,24 +112,6 @@ public abstract class OptionalActorInterfaceBase extends SystemPortOwner impleme
}
/**
- * This method is called by the optional actor factory to set the relative path mappings
- * for the created instance sub tree
- *
- * @param path2peers
- */
- public void setPath2peers(PathToPeers path2peers) {
- this.path2peers = path2peers;
- }
-
- /**
- * Returns the locally set path-to-peer mapping
- * @return the path2peers
- */
- protected PathToPeers getPath2peers() {
- return path2peers;
- }
-
- /**
* @return the class name for this optional actor
*/
public String getClassName() {
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PathToPeers.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PathToPeers.java
deleted file mode 100644
index 0007b34ca..000000000
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/PathToPeers.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.runtime.java.modelbase;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-
-/**
- * @author Henrik Rentz-Reichert
- *
- */
-public class PathToPeers extends HashMap<String, ArrayList<String>> {
-
- private static final long serialVersionUID = 1L;
-
- public void put(String key, String value) {
- ArrayList<String> list = get(key);
- if (list==null) {
- list = new ArrayList<String>();
- put(key, list);
- }
- list.add(value);
- }
-
- public void put(String key, Collection<String> values) {
- ArrayList<String> list = get(key);
- if (list==null) {
- list = new ArrayList<String>(values);
- put(key, list);
- }
- else
- list.addAll(values);
- }
-
- public void put(String key, String[] values) {
- List<String> list = Arrays.asList(values);
- put(key, list);
- }
-
-} \ No newline at end of file
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedInterfaceItemBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedInterfaceItemBase.java
index 2b757f02e..0ae2eb442 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedInterfaceItemBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedInterfaceItemBase.java
@@ -14,9 +14,7 @@ package org.eclipse.etrice.runtime.java.modelbase;
import java.util.ArrayList;
import java.util.LinkedList;
-import java.util.List;
-import org.eclipse.etrice.runtime.java.messaging.IRTObject;
import org.eclipse.etrice.runtime.java.messaging.RTObject;
/**
@@ -40,25 +38,6 @@ public abstract class ReplicatedInterfaceItemBase extends RTObject implements IR
super(owner, name);
this.localId = localId;
-
- List<String> peerPaths = getParent().getPeersForPath(getInstancePath());
- if (peerPaths!=null) {
- for (String path : peerPaths) {
- IRTObject object = getObject(path);
- InterfaceItemBase peer = null;
- if (object instanceof InterfaceItemBase) {
- peer = ((InterfaceItemBase) object);
- }
- else if (object instanceof IReplicatedInterfaceItem) {
- if (object!=this) // avoid connecting to myself: occurs in a special situation with optional actors
- peer = ((IReplicatedInterfaceItem) object).createSubInterfaceItem();
- }
- if (peer!=null) {
- InterfaceItemBase item = createSubInterfaceItem();
- item.connectWith(peer);
- }
- }
- }
}
/* (non-Javadoc)
@@ -75,7 +54,7 @@ public abstract class ReplicatedInterfaceItemBase extends RTObject implements IR
public void removeItem(InterfaceItemBase item) {
boolean isRemoved = items.remove(item);
assert(isRemoved): "is own child";
- if(isRemoved) {
+ if (isRemoved) {
releasedIndices.push(item.getIdx());
}
}
@@ -123,5 +102,9 @@ public abstract class ReplicatedInterfaceItemBase extends RTObject implements IR
return "replicated port "+getName();
}
+ public IInterfaceItem connectWith(IInterfaceItem peer) {
+ return peer.connectWith(createSubInterfaceItem());
+ }
+
protected abstract InterfaceItemBase createInterfaceItem(IInterfaceItemOwner rcv, String name, int lid, int idx);
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
index 498f6732e..66806a22f 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
@@ -8,9 +8,6 @@
package org.eclipse.etrice.runtime.java.modelbase;
-import java.util.Collection;
-import java.util.List;
-
import org.eclipse.etrice.runtime.java.config.IVariableService;
import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
import org.eclipse.etrice.runtime.java.messaging.Address;
@@ -39,7 +36,6 @@ public abstract class SubSystemClassBase extends RTObject implements IEventRecei
protected static final int IFITEM_RTSystemPort = 0;
private PathToThread path2thread = new PathToThread();
- private PathToPeers path2peers = new PathToPeers();
// for tests only
private TestSemaphore terminateSem=null;
@@ -190,47 +186,12 @@ public abstract class SubSystemClassBase extends RTObject implements IEventRecei
}
/**
- * add a peer for the given path
- * @param path
- * @param peer
- */
- public void addPathToPeer(String path, String peer) {
- path2peers.put(path, peer);
- }
-
- /**
- * add a collection of peers to the given path
- * @param path
- * @param peers
- */
- public void addPathToPeers(String path, Collection<String> peers) {
- path2peers.put(path, peers);
- }
-
- /**
- * add several peers to the given path
- * @param path
- * @param peers
- */
- public void addPathToPeers(String path, String... peers) {
- path2peers.put(path, peers);
- }
-
- /**
- * @param path
- * @return list of peer paths
- */
- public List<String> getPeersForPath(String path) {
- return path2peers.get(path);
- }
-
- /**
* Clears thread and peer mappings.
*/
public void resetAll() {
- path2peers.clear();
path2thread.clear();
}
+
/**
* @param optionalActorClass
* @param instanceActorClass

Back to the top