Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-08-09 13:36:26 -0400
committerHenrik Rentz-Reichert2013-08-09 13:36:26 -0400
commit8ea61c85f6c14de12f1be0da43dbf188097a14f8 (patch)
tree353f386977f37a3ad28f20641c6173a264905cd6 /runtime/org.eclipse.etrice.runtime.java/src/org/eclipse
parent7372d82d9e63d31168c7033edf8e18b991c9c853 (diff)
downloadorg.eclipse.etrice-8ea61c85f6c14de12f1be0da43dbf188097a14f8.tar.gz
org.eclipse.etrice-8ea61c85f6c14de12f1be0da43dbf188097a14f8.tar.xz
org.eclipse.etrice-8ea61c85f6c14de12f1be0da43dbf188097a14f8.zip
[runtime.java] bug 414790: [runtime.java] extend persistence mechanism to treat also nested dynamic actors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=414790
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/OptionalActorInterfaceBase.java6
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ReplicatedOptionalActorInterfaceBase.java33
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ScalarOptionalActorInterfaceBase.java29
3 files changed, 66 insertions, 2 deletions
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 71de950b5..4231106ba 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
@@ -391,6 +391,9 @@ public abstract class OptionalActorInterfaceBase extends SystemPortOwner impleme
for (IRTObject child : actor.getChildren()) {
if (child instanceof ActorClassBase)
recursivelyLoad((ActorClassBase) child, input);
+ else if (child instanceof IPersistable) {
+ ((IPersistable) child).loadObject(input);
+ }
}
}
}
@@ -431,6 +434,9 @@ public abstract class OptionalActorInterfaceBase extends SystemPortOwner impleme
for (IRTObject child : actor.getChildren()) {
if (child instanceof ActorClassBase)
recursivelySave((ActorClassBase) child, output);
+ else if (child instanceof IPersistable) {
+ ((IPersistable) child).saveObject(output);
+ }
}
}
}
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 68900184f..4ffa4cd1c 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
@@ -12,6 +12,7 @@
package org.eclipse.etrice.runtime.java.modelbase;
+import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
@@ -28,7 +29,7 @@ import org.eclipse.etrice.runtime.java.messaging.RTServices;
*
* @author Henrik Rentz-Reichert
*/
-public class ReplicatedOptionalActorInterfaceBase extends OptionalActorInterfaceBase {
+public class ReplicatedOptionalActorInterfaceBase extends OptionalActorInterfaceBase implements IPersistable {
/**
* A separator for the index part of the name.
@@ -180,4 +181,34 @@ public class ReplicatedOptionalActorInterfaceBase extends OptionalActorInterface
return "ReplicatedOptionalActorInterface(className="+getClassName()+", instancePath="+getInterfaceInstancePath()+")";
}
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.runtime.java.modelbase.IPersistable#saveObject(java.io.ObjectOutput)
+ */
+ @Override
+ public void saveObject(ObjectOutput output) throws IOException {
+ output.writeInt(actors.size());
+ for (ActorClassBase actor : actors) {
+ output.writeUTF(actor.getClassName());
+ output.writeInt(actor.getThread());
+ int idx = Integer.parseInt(actor.getName().substring(actor.getName().indexOf(INDEX_SEP)+1));
+ output.writeInt(idx);
+ saveActor(actor, output);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.runtime.java.modelbase.IPersistable#loadObject(java.io.ObjectInput)
+ */
+ @Override
+ public void loadObject(ObjectInput input) throws IOException, ClassNotFoundException {
+ int size = input.readInt();
+ for (int i=0; i<size; ++i) {
+ String className = input.readUTF();
+ int thread = input.readInt();
+ int idx = input.readInt();
+ releasedIndices.add(idx); // will be used as next index
+ createOptionalActor(className, thread, input);
+ }
+ }
+
}
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 2a01006c9..5ca740e90 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
@@ -12,6 +12,7 @@
package org.eclipse.etrice.runtime.java.modelbase;
+import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
@@ -25,7 +26,7 @@ import org.eclipse.etrice.runtime.java.messaging.RTServices;
*
* @author Henrik Rentz-Reichert
*/
-public class ScalarOptionalActorInterfaceBase extends OptionalActorInterfaceBase {
+public class ScalarOptionalActorInterfaceBase extends OptionalActorInterfaceBase implements IPersistable {
/**
* Our single actor instance or {@code null} if not instantiated or destroyed.
@@ -117,4 +118,30 @@ public class ScalarOptionalActorInterfaceBase extends OptionalActorInterfaceBase
return "ScalarOptionalActorInterface(className="+getClassName()+", instancePath="+getInterfaceInstancePath()+")";
}
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.runtime.java.modelbase.IPersistable#saveObject(java.io.ObjectOutput)
+ */
+ @Override
+ public void saveObject(ObjectOutput output) throws IOException {
+ output.writeBoolean(actor!=null);
+ if (actor!=null) {
+ output.writeUTF(actor.getClassName());
+ output.writeInt(actor.getThread());
+ saveActor(actor, output);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.etrice.runtime.java.modelbase.IPersistable#loadObject(java.io.ObjectInput)
+ */
+ @Override
+ public void loadObject(ObjectInput input) throws IOException, ClassNotFoundException {
+ boolean haveActor = input.readBoolean();
+ if (haveActor) {
+ String className = input.readUTF();
+ int thread = input.readInt();
+ createOptionalActor(className, thread, input);
+ }
+ }
+
}

Back to the top