fabric.common
Class SerializedObject

java.lang.Object
  extended by fabric.common.SerializedObject
All Implemented Interfaces:
FastSerializable, java.io.Serializable

public final class SerializedObject
extends java.lang.Object
implements FastSerializable, java.io.Serializable

_Impl objects are stored on stores in serialized form as SerializedObjects.

See Also:
Serialized Form

Constructor Summary
SerializedObject(java.io.DataInput in)
          A deserialization constructor.
SerializedObject(long onum, long label, Pair<java.lang.String,java.lang.Long> remoteRef)
          Creates a serialized representation of a surrogate object.
SerializedObject(Object._Impl obj)
          Deprecated.  
 
Method Summary
 Object._Impl deserialize(Store store)
          Used by the worker to deserialize this object.
 java.lang.String getClassName()
           
 fabric.lang.Codebase getCodebase()
           
 long getExpiry()
           
 ComparablePair<java.lang.String,java.lang.Long> getInterStoreLabelRef()
           
 java.util.Iterator<ComparablePair<java.lang.String,java.lang.Long>> getInterStoreRefIterator()
           
 java.util.Iterator<java.lang.Long> getIntraStoreRefIterator()
           
 long getLabelOnum()
           
 int getNumInterStoreRefs()
           
 int getNumIntraStoreRefs()
           
 int getNumRefTypes()
           
 long getOnum()
           
 java.util.Iterator<RefTypeEnum> getRefTypeIterator()
           
 java.io.InputStream getSerializedDataStream()
           
 int getVersion()
           
 boolean isSystemClass()
           
 boolean labelRefIsInterStore()
           
 void setExpiry(long expiry)
          Modifies the serialized object's promise expiry
 void setRefs(java.util.List<java.lang.Long> intraStoreRefs)
          Replaces the intra-store and inter-store references with the given intra-store references.
 void setVersion(int version)
          Modifies the serialized object's version number.
 java.lang.String toString()
           
 void write(java.io.DataOutput out)
          Writes this SerializedObject out to the given output stream.
static void write(Object._Impl impl, java.io.DataOutput out)
          Writes the given _Impl out to the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SerializedObject

public SerializedObject(Object._Impl obj)
Deprecated. 

Creates a serialized representation of the given object. This should only be used by fabric.store.InProcessStore and for debugging (worker.debug.*).

Parameters:
obj - The object to serialize.

SerializedObject

public SerializedObject(long onum,
                        long label,
                        Pair<java.lang.String,java.lang.Long> remoteRef)
Creates a serialized representation of a surrogate object.

Parameters:
onum - The local object number for the surrogate.
label - The onum for the surrogate's label object.
remoteRef - The name of the remote object being referred to.

SerializedObject

public SerializedObject(java.io.DataInput in)
                 throws java.io.IOException
A deserialization constructor.

Parameters:
in - An input stream containing a serialized object.
Throws:
java.io.IOException
See Also:
write(DataOutput), #write(_Impl, DataOutput), #readImpl(Store, DataInput)
Method Detail

getOnum

public long getOnum()

getVersion

public int getVersion()
Returns:
the serialized object's version number.

setVersion

public void setVersion(int version)
Modifies the serialized object's version number.


getExpiry

public long getExpiry()
Returns:
the serialized object's promise expiration time

setExpiry

public void setExpiry(long expiry)
Modifies the serialized object's promise expiry

Parameters:
expiry -

labelRefIsInterStore

public boolean labelRefIsInterStore()
Returns:
whether the reference to the serialized object's label is an inter-store reference.

getInterStoreLabelRef

public ComparablePair<java.lang.String,java.lang.Long> getInterStoreLabelRef()
Returns:
an inter-store reference to the the serialized object's label.
Throws:
InternalError - if the serialized object has an intra-store reference to its label.

getLabelOnum

public long getLabelOnum()
Returns:
an intra-store reference to the serialized object's label.
Throws:
InternalError - if the serialized object has an inter-store reference to its label.

isSystemClass

public boolean isSystemClass()
Returns:
whether the class of the serialized object is a system class.

getCodebase

public fabric.lang.Codebase getCodebase()
Returns:
the codebase of the serialized object's class or null for system classes.

getClassName

public java.lang.String getClassName()
Returns:
the serialized object's class name.

getNumRefTypes

public final int getNumRefTypes()
Returns:
the number of references in the serialized object. (See RefTypeEnum.)

getNumIntraStoreRefs

public final int getNumIntraStoreRefs()
Returns:
the number of intra-store references in the serialized object.

getNumInterStoreRefs

public final int getNumInterStoreRefs()
Returns:
the number of inter-store references in the serialized object.

getRefTypeIterator

public java.util.Iterator<RefTypeEnum> getRefTypeIterator()
Returns:
an Iterator for the serialized object's reference types.

getIntraStoreRefIterator

public java.util.Iterator<java.lang.Long> getIntraStoreRefIterator()
Returns:
an Iterator for the serialized object's intra-store references.

getSerializedDataStream

public java.io.InputStream getSerializedDataStream()
Returns:
an InputStream for the Java-serialized data segment in the serialized object.

getInterStoreRefIterator

public java.util.Iterator<ComparablePair<java.lang.String,java.lang.Long>> getInterStoreRefIterator()
Returns:
an Iterator for the serialized object's inter-store references.

setRefs

public void setRefs(java.util.List<java.lang.Long> intraStoreRefs)
Replaces the intra-store and inter-store references with the given intra-store references. It is assumed that all inter-store references are being replaced with intra-store references.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

write

public static void write(Object._Impl impl,
                         java.io.DataOutput out)
                  throws java.io.IOException
Writes the given _Impl out to the given output stream. The behaviour of this method should mirror write(DataOutput).

Throws:
java.io.IOException
See Also:
write(DataOutput), #readImpl(Store, DataInput), SerializedObject(DataInput)

write

public void write(java.io.DataOutput out)
           throws java.io.IOException
Writes this SerializedObject out to the given output stream. The behavior of this method should mirror write(_Impl, DataOutput).

Specified by:
write in interface FastSerializable
Throws:
java.io.IOException
See Also:
SerializedObject#write(_Impl, DataOutput), SerializedObject#readImpl(Store, DataInput), SerializedObject(DataInput)

deserialize

public Object._Impl deserialize(Store store)
Used by the worker to deserialize this object.

Parameters:
store - The store on which this object lives.
Returns:
The deserialized object.
Throws:
java.lang.ClassNotFoundException - Thrown when the class for this object is unavailable.