Class AnnotatedObjectOutputStream

java.lang.Object
java.io.OutputStream
java.io.ObjectOutputStream
com.gigaspaces.internal.io.AnnotatedObjectOutputStream
All Implemented Interfaces:
Closeable, DataOutput, Flushable, ObjectOutput, ObjectStreamConstants, AutoCloseable
Direct Known Subclasses:
MarshalOutputStream

public class AnnotatedObjectOutputStream extends ObjectOutputStream
An extension of ObjectOutputStream that implements the dynamic class loading semantics of RMI argument and result marshalling (using RMIClassLoader). A AnnotatedObjectOutputStream writes data that is intended to be written by a corresponding AnnotatedObjectInputStream.

AnnotatedObjectOutputStream implements the output side of the dynamic class loading semantics by overriding annotateClass and annotateProxyClass to annotate class descriptors in the stream with codebase strings obtained using RMIClassLoader.getClassAnnotation.

AnnotatedObjectOutputStream writes class annotations to its own stream; a subclass may override the writeAnnotation method to write the class annotations to a different location.

AnnotatedObjectOutputStream does not modify the stream protocol version of its instances' superclass state (see ObjectOutputStream.useProtocolVersion).

Since:
5.1
Author:
Igor Goldenberg, anna
  • Constructor Details

    • AnnotatedObjectOutputStream

      public AnnotatedObjectOutputStream(OutputStream out) throws IOException
      Creates a new AnnotatedObjectOutputStream that writes marshaled data to the specified underlying OutputStream.

      This constructor passes out to the superclass constructor that has an OutputStream parameter.

      context will be used as the return value of the created stream's getObjectStreamContext method.

      Parameters:
      out - the output stream to write marshaled data to
      context - the collection of context information objects to be returned by this stream's getObjectStreamContext method
      Throws:
      IOException - if the superclass's constructor throws an IOException
      SecurityException - if the superclass's constructor throws a SecurityException
      NullPointerException - if out or context is null
  • Method Details

    • annotateClass

      protected void annotateClass(Class cl) throws IOException
      Annotates the stream descriptor for the class cl.

      AnnotatedObjectOutputStream implements this method as follows:

      This method invokes this stream's writeAnnotation method with the given cl.

      Overrides:
      annotateClass in class ObjectOutputStream
      Parameters:
      cl - the class to annotate
      Throws:
      IOException - if writeAnnotation throws an IOException
      NullPointerException - if cl is null
    • annotateProxyClass

      protected void annotateProxyClass(Class cl) throws IOException
      Annotates the stream descriptor for the proxy class cl.

      AnnotatedObjectOutputStream implements this method as follows:

      This method invokes this stream's writeAnnotation method with the given cl.

      Overrides:
      annotateProxyClass in class ObjectOutputStream
      Parameters:
      cl - the proxy class to annotate
      Throws:
      IOException - if writeAnnotation throws an IOException
      NullPointerException - if cl is null
    • writeAnnotation

      protected void writeAnnotation(Class cl) throws IOException
      First checks that this class wasn't written already, if it does do nothing.

      Else invokes RMIClassLoader.getClassAnnotation with cl to get the appropriate class annotation string value (possibly null) and then writes a class annotation string value (possibly null) to be read by a corresponding AnnotatedObjectInputStream implementation.

      AnnotatedObjectOutputStream implements this method to just write the annotation value to this stream using writeUnshared.

      A subclass can override this method to write the annotation to a different location.

      Parameters:
      annotation - the class annotation string value (possibly null) to write
      Throws:
      IOException - if I/O exception occurs writing the annotation