public class

MarshalOutputStream

extends ObjectOutputStream
java.lang.Object
   ↳ java.io.OutputStream
     ↳ java.io.ObjectOutputStream
       ↳ sun.rmi.server.MarshalOutputStream

Class Overview

A MarshalOutputStream extends ObjectOutputStream to add functions specific to marshaling of remote object references. If it is necessary to serialize remote objects or objects that contain references to remote objects a MarshalOutputStream must be used instead of ObjectOutputStream.

A new MarshalOutputStream is constructed to serialize remote objects or graphs containing remote objects. Objects are written to the stream using the ObjectOutputStream.writeObject method.

MarshalOutputStream maps remote objects to the corresponding remote stub and embeds the location from which to load the stub classes. The location may be ignored by the client but is supplied.

Summary

[Expand]
Inherited Constants
From interface java.io.ObjectStreamConstants
[Expand]
Inherited Fields
From interface java.io.ObjectStreamConstants
Public Constructors
MarshalOutputStream(OutputStream out)
Creates a marshal output stream with protocol version 1.
MarshalOutputStream(OutputStream out, int protocolVersion)
Creates a marshal output stream with the given protocol version.
Protected Methods
void annotateClass(Class<?> cl)
Serializes a location from which to load the the specified class.
void annotateProxyClass(Class<?> cl)
Serializes a location from which to load the specified class.
final Object replaceObject(Object obj)
Checks for objects that are instances of java.rmi.Remote that need to be serialized as proxy objects.
void writeLocation(String location)
Writes the location for the class into the stream.
[Expand]
Inherited Methods
From class java.io.ObjectOutputStream
From class java.io.OutputStream
From class java.lang.Object
From interface java.io.Closeable
From interface java.io.DataOutput
From interface java.io.Flushable
From interface java.io.ObjectOutput

Public Constructors

public MarshalOutputStream (OutputStream out)

Creates a marshal output stream with protocol version 1.

Throws
IOException

public MarshalOutputStream (OutputStream out, int protocolVersion)

Creates a marshal output stream with the given protocol version.

Throws
IOException

Protected Methods

protected void annotateClass (Class<?> cl)

Serializes a location from which to load the the specified class.

Parameters
cl the class to annotate custom data for
Throws
IOException

protected void annotateProxyClass (Class<?> cl)

Serializes a location from which to load the specified class.

Parameters
cl the proxy class to annotate custom data for
Throws
IOException

protected final Object replaceObject (Object obj)

Checks for objects that are instances of java.rmi.Remote that need to be serialized as proxy objects.

Parameters
obj the object to be replaced
Returns
  • the alternate object that replaced the specified one
Throws
IOException

protected void writeLocation (String location)

Writes the location for the class into the stream. This method can be overridden by subclasses that store this annotation somewhere else than as the next object in the stream, as is done by this class.

Throws
IOException