Top Description Constructors Methods
sun.rmi.server

public Class MarshalOutputStream

extends ObjectOutputStream
Class Inheritance
Known Direct Subclasses
sun.rmi.transport.ConnectionOutputStream, java.rmi.MarshalledObject.MarshalledObjectOutputStream
Imports
java.io.*, java.rmi.Remote, java.rmi.server.RemoteStub, sun.rmi.transport.ObjectTable, .Target

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.

Constructor Summary

AccessConstructor and Description
public
MarshalOutputStream(OutputStream out)

Creates a marshal output stream with protocol version 1.

public
MarshalOutputStream(OutputStream out, int protocolVersion)

Creates a marshal output stream with the given protocol version.

Method Summary

Modifier and TypeMethod and Description
protected void
annotateClass(Class<?>
the class to annotate custom data for
cl
)

Overrides java.io.ObjectOutputStream.annotateClass.

Serializes a location from which to load the specified class.
protected void
annotateProxyClass(Class<?>
the proxy class to annotate custom data for
cl
)

Overrides java.io.ObjectOutputStream.annotateProxyClass.

Serializes a location from which to load the specified class.
protected final Object
replaceObject(Object
the object to be replaced
obj
)

Overrides java.io.ObjectOutputStream.replaceObject.

Checks for objects that are instances of java.rmi.Remote that need to be serialized as proxy objects.
protected void
writeLocation(String location)

Writes the location for the class into the stream.

Inherited from java.io.ObjectOutputStream:
closedefaultWriteObjectdrainenableReplaceObjectflushputFieldsresetuseProtocolVersionwritewritewritewriteBooleanwriteBytewriteByteswriteCharwriteCharswriteClassDescriptorwriteDoublewriteFieldswriteFloatwriteIntwriteLongwriteObjectwriteObjectOverridewriteShortwriteStreamHeaderwriteUnsharedwriteUTF

Constructor Detail

MarshalOutputStreamback to summary
public MarshalOutputStream(OutputStream out) throws IOException

Creates a marshal output stream with protocol version 1.

MarshalOutputStreamback to summary
public MarshalOutputStream(OutputStream out, int protocolVersion) throws IOException

Creates a marshal output stream with the given protocol version.

Annotations
@SuppressWarnings:removal

Method Detail

annotateClassback to summary
protected void annotateClass(Class<?> cl) throws IOException

Overrides java.io.ObjectOutputStream.annotateClass.

Serializes a location from which to load the specified class.

Parameters
cl:Class<?>

Doc from java.io.ObjectOutputStream.annotateClass.

the class to annotate custom data for

Exceptions
IOException:

Doc from java.io.ObjectOutputStream.annotateClass.

Any exception thrown by the underlying OutputStream.

annotateProxyClassback to summary
protected void annotateProxyClass(Class<?> cl) throws IOException

Overrides java.io.ObjectOutputStream.annotateProxyClass.

Serializes a location from which to load the specified class.

Parameters
cl:Class<?>

Doc from java.io.ObjectOutputStream.annotateProxyClass.

the proxy class to annotate custom data for

Exceptions
IOException:

Doc from java.io.ObjectOutputStream.annotateProxyClass.

any exception thrown by the underlying OutputStream

replaceObjectback to summary
protected final Object replaceObject(Object obj) throws IOException

Overrides java.io.ObjectOutputStream.replaceObject.

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

Parameters
obj:Object

Doc from java.io.ObjectOutputStream.replaceObject.

the object to be replaced

Returns:Object

Doc from java.io.ObjectOutputStream.replaceObject.

the alternate object that replaced the specified one

Annotations
@SuppressWarnings:deprecation
Exceptions
IOException:

Doc from java.io.ObjectOutputStream.replaceObject.

Any exception thrown by the underlying OutputStream.

writeLocationback to summary
protected void writeLocation(String location) throws IOException

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.