Class AnnotatedObjectOutputStream
- All Implemented Interfaces:
Closeable,DataOutput,Flushable,ObjectOutput,ObjectStreamConstants,AutoCloseable
- Direct Known Subclasses:
MarshalOutputStream
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
-
Nested Class Summary
Nested classes/interfaces inherited from class java.io.ObjectOutputStream
ObjectOutputStream.PutField -
Field Summary
Fields inherited from interface java.io.ObjectStreamConstants
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, SERIAL_FILTER_PERMISSION, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newAnnotatedObjectOutputStreamthat writes marshaled data to the specified underlyingOutputStream. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidannotateClass(Class cl) Annotates the stream descriptor for the classcl.protected voidAnnotates the stream descriptor for the proxy classcl.protected voidwriteAnnotation(Class cl) First checks that this class wasn't written already, if it does do nothing.Methods inherited from class java.io.ObjectOutputStream
close, defaultWriteObject, drain, enableReplaceObject, flush, putFields, replaceObject, reset, useProtocolVersion, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeClassDescriptor, writeDouble, writeFields, writeFloat, writeInt, writeLong, writeObject, writeObjectOverride, writeShort, writeStreamHeader, writeUnshared, writeUTFMethods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
AnnotatedObjectOutputStream
Creates a newAnnotatedObjectOutputStreamthat writes marshaled data to the specified underlyingOutputStream.This constructor passes
outto the superclass constructor that has anOutputStreamparameter.contextwill be used as the return value of the created stream'sgetObjectStreamContextmethod.- Parameters:
out- the output stream to write marshaled data tocontext- the collection of context information objects to be returned by this stream'sgetObjectStreamContextmethod- Throws:
IOException- if the superclass's constructor throws anIOExceptionSecurityException- if the superclass's constructor throws aSecurityExceptionNullPointerException- ifoutorcontextisnull
-
-
Method Details
-
annotateClass
Annotates the stream descriptor for the classcl.AnnotatedObjectOutputStreamimplements this method as follows:This method invokes this stream's
writeAnnotationmethod with the given cl.- Overrides:
annotateClassin classObjectOutputStream- Parameters:
cl- the class to annotate- Throws:
IOException- ifwriteAnnotationthrows anIOExceptionNullPointerException- ifclisnull
-
annotateProxyClass
Annotates the stream descriptor for the proxy classcl.AnnotatedObjectOutputStreamimplements this method as follows:This method invokes this stream's
writeAnnotationmethod with the given cl.- Overrides:
annotateProxyClassin classObjectOutputStream- Parameters:
cl- the proxy class to annotate- Throws:
IOException- ifwriteAnnotationthrows anIOExceptionNullPointerException- ifclisnull
-
writeAnnotation
First checks that this class wasn't written already, if it does do nothing.Else invokes
RMIClassLoader.getClassAnnotationwithclto get the appropriate class annotation string value (possiblynull) and then writes a class annotation string value (possiblynull) to be read by a correspondingAnnotatedObjectInputStreamimplementation.AnnotatedObjectOutputStreamimplements this method to just write the annotation value to this stream usingwriteUnshared.A subclass can override this method to write the annotation to a different location.
- Parameters:
annotation- the class annotation string value (possiblynull) to write- Throws:
IOException- if I/O exception occurs writing the annotation
-