uka.transport
Class TransportDescriptor

java.lang.Object
  extended byuka.transport.TransportDescriptor
All Implemented Interfaces:
TransportConstants

public abstract class TransportDescriptor
extends java.lang.Object
implements TransportConstants

A transport descriptor either provides access to an object's mashaling and unmarshaling routines, or implements marshaling outside the object's class. The second case is useful, when marshaling functionality should be provided for library classes.

Each transportable class requires an associated TransportDescriptor.

Associating a TransportDescriptor with a class can be done in two ways:

The default way to declare a class transportable is to implement the Transportable interface and a special constructor with the same signature as the method {#unmarshalReference}. The corresponding transport descriptor can then simply forward calls to the appropriate methods of the object.

Note: The JavaParty compiler does automatically make classes transportable. When compiling your source files with JavaParty, it should not be necessary to deal with transport related methods and interfaces.

  • For fast local deep cloning, the class must provide an implementation of the deepClone(java.lang.Object, int, uka.transport.DeepClone) method. See DeepClone for details.
  • Author:
    Bernhard Haumacher

    Field Summary
     
    Fields inherited from interface uka.transport.TransportConstants
    REQUEST_MAX, REQUEST_MAX_boolean, REQUEST_MAX_byte, REQUEST_MAX_char, REQUEST_MAX_double, REQUEST_MAX_float, REQUEST_MAX_int, REQUEST_MAX_long, REQUEST_MAX_short, SIZEOF_boolean, SIZEOF_byte, SIZEOF_char, SIZEOF_double, SIZEOF_float, SIZEOF_int, SIZEOF_long, SIZEOF_short, TC_ANONYMOUS, TC_DEFAULT, TC_EXCEPTION, TC_NEW, TC_NULL, TC_REFERENCE, TC_REPLACEMENT, TC_RESET, TC_RESETTYPE, TC_TYPE, TC_USER
     
    Constructor Summary
    TransportDescriptor()
               
     
    Method Summary
    abstract  java.lang.Object deepClone(java.lang.Object obj, int id, DeepClone helper)
              Creates a deep clone of the given object.
     boolean deepCloneReferences(java.lang.Object orig, java.lang.Object copy, DeepClone helper)
               
    abstract  java.lang.Class getType()
              Return the class, this transport descriptor is associated with.
     void marshal(java.lang.Object obj, MarshalStream s)
              Marshals all non-final fields of the given object to the stream.
     void marshalReference(java.lang.Object obj, MarshalStream s)
              Marshals all final fields of the given object to the stream.
     void restoreAfterUnmarshal(java.lang.Object obj)
               
     boolean unmarshal(java.lang.Object obj, UnmarshalStream s)
              Unmarshals all non-final fields of the given object.
    abstract  java.lang.Object unmarshalReference(UnmarshalStream s, int id)
              Calls the unmarshaling constructor of the associated class and returns the newly created object.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    TransportDescriptor

    public TransportDescriptor()
    Method Detail

    unmarshalReference

    public abstract java.lang.Object unmarshalReference(UnmarshalStream s,
                                                        int id)
                                                 throws java.lang.ClassNotFoundException,
                                                        java.io.IOException
    Calls the unmarshaling constructor of the associated class and returns the newly created object. The unmarshaling constructor must UnmarshalStream.register(java.lang.Object, int) the created object with the stream under the given id, and read all final fields from the stream.

    Throws:
    java.lang.ClassNotFoundException
    java.io.IOException

    unmarshal

    public boolean unmarshal(java.lang.Object obj,
                             UnmarshalStream s)
                      throws java.lang.ClassNotFoundException,
                             java.io.IOException
    Unmarshals all non-final fields of the given object. This method is called during the unmarshaling process, after the object is constructed in the unmarshalReference(uka.transport.UnmarshalStream, int) method.

    Throws:
    java.lang.ClassNotFoundException
    java.io.IOException
    See Also:
    Transportable.unmarshal(uka.transport.UnmarshalStream)

    marshalReference

    public void marshalReference(java.lang.Object obj,
                                 MarshalStream s)
                          throws java.io.IOException
    Marshals all final fields of the given object to the stream.

    Throws:
    java.io.IOException
    See Also:
    Transportable.marshalReference(uka.transport.MarshalStream)

    marshal

    public void marshal(java.lang.Object obj,
                        MarshalStream s)
                 throws java.io.IOException
    Marshals all non-final fields of the given object to the stream.

    Throws:
    java.io.IOException
    See Also:
    Transportable.marshal(uka.transport.MarshalStream)

    deepClone

    public abstract java.lang.Object deepClone(java.lang.Object obj,
                                               int id,
                                               DeepClone helper)
                                        throws java.lang.CloneNotSupportedException
    Creates a deep clone of the given object. The given helper object is used to resolve references to already cloned objects in a graph. The result must be identical to marshaling the given object and immediately reading it back from a MarshalStream/UnmarshalStream pair.

    Throws:
    java.lang.CloneNotSupportedException

    deepCloneReferences

    public boolean deepCloneReferences(java.lang.Object orig,
                                       java.lang.Object copy,
                                       DeepClone helper)
                                throws java.lang.CloneNotSupportedException
    Throws:
    java.lang.CloneNotSupportedException

    restoreAfterUnmarshal

    public void restoreAfterUnmarshal(java.lang.Object obj)
                               throws java.lang.ClassNotFoundException,
                                      java.io.IOException
    Throws:
    java.lang.ClassNotFoundException
    java.io.IOException

    getType

    public abstract java.lang.Class getType()
    Return the class, this transport descriptor is associated with.