org.eclipse.ecf.core.sharedobject.util
Interface ISharedObjectMessageSerializer


public interface ISharedObjectMessageSerializer

Serialize/deserialize shared object messages. Instances of this class can be provided to an ISharedObjectContainer (via ISOC.setSharedObjectMessageSerializer) to customize the shared object message serialization. Note that the serializer has to be symmetric, and able to deserialize objects of all relevant classes.

Since:
2.0

Method Summary
 java.lang.Object deserializeMessage(byte[] data)
           Deserialize a byte array into an object message.
 byte[] serializeMessage(ID sharedObjectID, java.lang.Object message)
           Serialize an object to byte array.
 

Method Detail

serializeMessage

byte[] serializeMessage(ID sharedObjectID,
                        java.lang.Object message)
                        throws java.io.IOException

Serialize an object to byte array. This method will be called every time a shared object message is sent from one shared object instance to its replica.

Note that this method may be called many times, and should perform as rapidly as possible to support good marshalling performance.

Parameters:
sharedObjectID - the ID for the sender shared object. Will not be null.
message - the object to be serialized as the message.
Returns:
byte[] that can be deserialized by deserializeMessage(byte[]) into a corresponding object on a compatible container instance. Must not be null.
Throws:
java.io.IOException - thrown if data cannot be serialized. Note that exceptions thrown will result in container-level disconnection.

deserializeMessage

java.lang.Object deserializeMessage(byte[] data)
                                    throws java.io.IOException,
                                           java.lang.ClassNotFoundException

Deserialize a byte array into an object message. This method will be called every time a shared object message is received, but before the resulting Object is delivered to the shared object.

Note that this method may be called many times, and should perform as rapidly as possible to support good marshalling performance.

Parameters:
data - the data to use to deserialize. Will not be null.
Returns:
Object that is the deserialized instance of the Object.
Throws:
java.io.IOException - if some problem deserializing from given bytes.
java.lang.ClassNotFoundException - thrown if class encoded in byte[] cannot be found in local runtime. Note that exceptions thrown will result in container-level disconnection.