diff options
| author | Paul Buetow <paul@buetow.org> | 2008-06-03 16:41:37 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-06-03 16:41:37 +0000 |
| commit | 11af1c9fa7fe66e10de0a92878311b4e22befb0f (patch) | |
| tree | 8dfc7af2ec18eb5889327426bc6fdb7379a3feba /sources/events | |
| parent | f7bdf8a7f6ebd43bfacc22eeeda3eb52bf50efd7 (diff) | |
made future serialized class versions backwards compatible.
Diffstat (limited to 'sources/events')
| -rw-r--r-- | sources/events/VSAbstractEvent.java | 12 | ||||
| -rw-r--r-- | sources/events/internal/VSMessageReceiveEvent.java | 40 | ||||
| -rw-r--r-- | sources/events/internal/VSProtocolEvent.java | 16 | ||||
| -rw-r--r-- | sources/events/internal/VSProtocolScheduleEvent.java | 37 |
4 files changed, 104 insertions, 1 deletions
diff --git a/sources/events/VSAbstractEvent.java b/sources/events/VSAbstractEvent.java index 0dd814c..0bc5ec8 100644 --- a/sources/events/VSAbstractEvent.java +++ b/sources/events/VSAbstractEvent.java @@ -177,9 +177,15 @@ abstract public class VSAbstractEvent extends VSPrefs { if (VSSerialize.DEBUG) System.out.println("Serializing: VSAbstractEvent; id="+getID()); + /** For later backwards compatibility, to add more stuff */ + objectOutputStream.writeObject(new Boolean(false)); + objectOutputStream.writeObject(new Integer(super.getID())); objectOutputStream.writeObject(eventShortname); objectOutputStream.writeObject(eventClassname); + + /** For later backwards compatibility, to add more stuff */ + objectOutputStream.writeObject(new Boolean(false)); } /* (non-Javadoc) @@ -195,6 +201,9 @@ abstract public class VSAbstractEvent extends VSPrefs { if (VSSerialize.DEBUG) System.out.print("Deserializing: VSAbstractEvent "); + /** For later backwards compatibility, to add more stuff */ + objectInputStream.readObject(); + int id = ((Integer) objectInputStream.readObject()).intValue(); this.eventShortname = (String) objectInputStream.readObject(); this.eventClassname = (String) objectInputStream.readObject(); @@ -203,5 +212,8 @@ abstract public class VSAbstractEvent extends VSPrefs { System.out.println(eventClassname); serialize.setObject(id, "event", this); + + /** For later backwards compatibility, to add more stuff */ + objectInputStream.readObject(); } } diff --git a/sources/events/internal/VSMessageReceiveEvent.java b/sources/events/internal/VSMessageReceiveEvent.java index 0cffa86..8972ce5 100644 --- a/sources/events/internal/VSMessageReceiveEvent.java +++ b/sources/events/internal/VSMessageReceiveEvent.java @@ -23,9 +23,12 @@ package events.internal; +import java.io.*; + import core.VSMessage; import events.VSAbstractEvent; import protocols.VSAbstractProtocol; +import serialize.VSSerialize; /** * The class VSMessageReceiveEvent. This event is used if a process receives @@ -106,4 +109,41 @@ public class VSMessageReceiveEvent extends VSAbstractEvent { return true; } + + /* (non-Javadoc) + * @see serialize.VSSerializable#serialize(serialize.VSSerialize, + * java.io.ObjectOutputStream) + */ + public synchronized void serialize(VSSerialize serialize, + ObjectOutputStream objectOutputStream) + throws IOException { + super.serialize(serialize, objectOutputStream); + + /** For later backwards compatibility, to add more stuff */ + objectOutputStream.writeObject(new Boolean(false)); + + /** For later backwards compatibility, to add more stuff */ + objectOutputStream.writeObject(new Boolean(false)); + } + + /* (non-Javadoc) + * @see serialize.VSSerializable#deserialize(serialize.VSSerialize, + * java.io.ObjectInputStream) + */ + @SuppressWarnings("unchecked") + public synchronized void deserialize(VSSerialize serialize, + ObjectInputStream objectInputStream) + throws IOException, ClassNotFoundException { + super.deserialize(serialize, objectInputStream); + + if (VSSerialize.DEBUG) + System.out.println("Deserializing: VSProtocolEvent"); + + /** For later backwards compatibility, to add more stuff */ + objectInputStream.readObject(); + + /** For later backwards compatibility, to add more stuff */ + objectInputStream.readObject(); + + } } diff --git a/sources/events/internal/VSProtocolEvent.java b/sources/events/internal/VSProtocolEvent.java index 5f5ceb4..8d6b2dd 100644 --- a/sources/events/internal/VSProtocolEvent.java +++ b/sources/events/internal/VSProtocolEvent.java @@ -27,7 +27,7 @@ import java.io.*; import events.*; import protocols.VSAbstractProtocol; -import serialize.*; +import serialize.VSSerialize; /** * The class VSProtocolEvent. This event is used if a protocol (server or @@ -144,9 +144,16 @@ public class VSProtocolEvent extends VSAbstractEvent { ObjectOutputStream objectOutputStream) throws IOException { super.serialize(serialize, objectOutputStream); + + /** For later backwards compatibility, to add more stuff */ + objectOutputStream.writeObject(new Boolean(false)); + objectOutputStream.writeObject(protocolClassname); objectOutputStream.writeObject(new Boolean(isClientProtocol)); objectOutputStream.writeObject(new Boolean(isProtocolActivation)); + + /** For later backwards compatibility, to add more stuff */ + objectOutputStream.writeObject(new Boolean(false)); } /* (non-Javadoc) @@ -162,10 +169,17 @@ public class VSProtocolEvent extends VSAbstractEvent { if (VSSerialize.DEBUG) System.out.println("Deserializing: VSProtocolEvent"); + /** For later backwards compatibility, to add more stuff */ + objectInputStream.readObject(); + protocolClassname = (String) objectInputStream.readObject(); isClientProtocol = ((Boolean) objectInputStream.readObject()).booleanValue();; isProtocolActivation = ((Boolean) objectInputStream.readObject()).booleanValue();; + + /** For later backwards compatibility, to add more stuff */ + objectInputStream.readObject(); + } } diff --git a/sources/events/internal/VSProtocolScheduleEvent.java b/sources/events/internal/VSProtocolScheduleEvent.java index 912b552..99ae020 100644 --- a/sources/events/internal/VSProtocolScheduleEvent.java +++ b/sources/events/internal/VSProtocolScheduleEvent.java @@ -23,8 +23,11 @@ package events.internal; +import java.io.*; + import events.*; import protocols.VSAbstractProtocol; +import serialize.VSSerialize; /** * The class VSProtocolScheduleEvent. This event is used if a protocol (which @@ -110,4 +113,38 @@ public class VSProtocolScheduleEvent extends VSAbstractEvent { else protocol.onClientScheduleStart(); } + + /* (non-Javadoc) + * @see serialize.VSSerializable#serialize(serialize.VSSerialize, + * java.io.ObjectOutputStream) + */ + public synchronized void serialize(VSSerialize serialize, + ObjectOutputStream objectOutputStream) + throws IOException { + super.serialize(serialize, objectOutputStream); + + /** For later backwards compatibility, to add more stuff */ + objectOutputStream.writeObject(new Boolean(false)); + + /** For later backwards compatibility, to add more stuff */ + objectOutputStream.writeObject(new Boolean(false)); + } + + /* (non-Javadoc) + * @see serialize.VSSerializable#deserialize(serialize.VSSerialize, + * java.io.ObjectInputStream) + */ + @SuppressWarnings("unchecked") + public synchronized void deserialize(VSSerialize serialize, + ObjectInputStream objectInputStream) + throws IOException, ClassNotFoundException { + super.deserialize(serialize, objectInputStream); + + if (VSSerialize.DEBUG) + System.out.println("Deserializing: VSProtocolEvent"); + + /** For later backwards compatibility, to add more stuff */ + objectInputStream.readObject(); + + } } |
