groovyx.gpars.serial
Class WithSerialId

java.lang.Object
  extended by groovyx.gpars.serial.WithSerialId
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
DataflowExpression, MessageStream

public abstract class WithSerialId
extends java.lang.Object
implements java.io.Serializable

Base class for objects which can be exposed to remote nodes via serialization.

Main concept is following: - each object belongs to some LocalHost - every object can be exposed to any RemoteHost - on remote host object is represented by proxy usually called remote object - for serialization we use writeReplace method, which creates special handle to be serialized instead of the object - for deserialization handle's readResolve method creates remote object (proxy)

See Serializable for detailed description how methods writeReplace & readResolve works.

It is very important to know that (de)serialization never happens by itself but always happens in context of RemoteHost and (@link LocalHost}. Such context is used for right resolution/transformation of objects

Author:
Alex Tkachman
See Also:
Serialized Form

Field Summary
 SerialHandle serialHandle
          See SerialHandle class for details
private static long serialVersionUID
           
 
Constructor Summary
WithSerialId()
           
 
Method Summary
protected  RemoteHandle createRemoteHandle(SerialHandle handle, SerialContext host)
           
 SerialHandle getOrCreateSerialHandle()
          Gets serial handle for the object If needed new handle created and serialization host subscribed for the object handle
<T extends RemoteSerialized>
java.lang.Class<T>
getRemoteClass()
          Class of remote object to be created
protected  java.lang.Object writeReplace()
          Replace object by handle for serialization
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

serialHandle

public volatile SerialHandle serialHandle
See SerialHandle class for details

Constructor Detail

WithSerialId

public WithSerialId()
Method Detail

getOrCreateSerialHandle

public final SerialHandle getOrCreateSerialHandle()
Gets serial handle for the object If needed new handle created and serialization host subscribed for the object handle

Returns:
serial handle for the object

getRemoteClass

public <T extends RemoteSerialized> java.lang.Class<T> getRemoteClass()
Class of remote object to be created

Returns:
Throws UnsupportedOperationException

writeReplace

protected final java.lang.Object writeReplace()
                                       throws java.io.ObjectStreamException
Replace object by handle for serialization

Returns:
handle to serialize
Throws:
java.io.ObjectStreamException - If the object cannot be serialized

createRemoteHandle

protected RemoteHandle createRemoteHandle(SerialHandle handle,
                                          SerialContext host)

Copyright © 2008–2010 Václav Pech. All Rights Reserved.