public class AnnotatedObjectInputStream extends ObjectInputStream
ObjectInputStream that implements the dynamic class loading
semantics of RMI argument and result unmarshalling (using RMIClassLoader). A
AnnotatedObjectInputStream is intended to read data written by a corresponding
AnnotatedObjectOutputStream.
AnnotatedObjectInputStream implements the input side of the dynamic class loading
semantics by overriding resolveClass and resolveProxyClass to resolve class descriptors in the stream
using ClassLoading.loadClass and ClassLoading.loadProxyClass (which, in turn, use RMIClassLoader.loadClass and RMIClassLoader.loadProxyClass),
optionally with CodeBase annotation strings written by a AnnotatedObjectOutputStream.
AnnotatedObjectInputStream reads class annotations from its own stream; a
subclass can override the readAnnotation method to read the class
annotations from a different location.
A AnnotatedObjectInputStream is not guaranteed to be safe for concurrent use by
multiple threads.
ObjectInputStream.GetFieldbaseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, 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 and Description |
|---|
AnnotatedObjectInputStream(InputStream in)
Creates a new
AnnotatedObjectInputStream that reads marshalled data from the
specified underlying InputStream. |
| Modifier and Type | Method and Description |
|---|---|
protected String |
readAnnotation(ObjectStreamClass desc)
Reads and returns a class annotation string value (possibly
null) that was
written by a corresponding AnnotatedObjectOutputStream implementation. |
protected Class |
resolveClass(ObjectStreamClass classDesc) |
protected Class |
resolveClass(ObjectStreamClass classDesc,
boolean readAnnotation,
String codebase)
Resolves the appropriate
Class object for the stream class descriptor
classDesc. |
available, close, defaultReadObject, enableResolveObject, read, read, readBoolean, readByte, readChar, readClassDescriptor, readDouble, readFields, readFloat, readFully, readFully, readInt, readLine, readLong, readObject, readObjectOverride, readShort, readStreamHeader, readUnshared, readUnsignedByte, readUnsignedShort, readUTF, registerValidation, resolveObject, resolveProxyClass, skipBytesmark, markSupported, read, reset, skipclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitread, skippublic AnnotatedObjectInputStream(InputStream in) throws IOException
AnnotatedObjectInputStream that reads marshalled data from the
specified underlying InputStream.
This constructor passes in to the superclass constructor that has an
InputStream parameter.
defaultLoader will be passed as the defaultLoader argument to
ClassLoading.loadClass and ClassLoading.loadProxyClass whenever those methods are invoked by resolveClass and resolveProxyClass.
If verifyCodebaseIntegrity is true, then the created stream will
verify that all codebase annotation URLs that are used to load classes resolved by the stream
provide content integrity, and whenever Security.verifyCodebaseIntegrity is invoked to enforce that verification,
verifierLoader will be passed as the loader argument. See ClassLoading.loadClass and ClassLoading.loadProxyClass for details of how codebase integrity verification is
performed.
context will be used as the return value of the created stream's getObjectStreamContext method.
in - the input stream to read marshalled data fromdefaultLoader - the class loader value (possibly null) to pass as the
defaultLoader argument to ClassLoading
methodscontext - the collection of context information objects to be returned by this
stream's getObjectStreamContext methodIOException - if the superclass's constructor throws an IOExceptionSecurityException - if the superclass's constructor throws a SecurityExceptionNullPointerException - if in or context is nullprotected Class resolveClass(ObjectStreamClass classDesc, boolean readAnnotation, String codebase) throws IOException, ClassNotFoundException
Class object for the stream class descriptor
classDesc.
AnnotatedObjectInputStream implements this method as follows:
Invokes this stream's readAnnotation method to read the annotation
string value (possibly null) for the class descriptor. If
readAnnotation throws an exception, then this method throws that exception.
Otherwise, a codebase value is chosen as follows: if the useCodebaseAnnotations method has been invoked on this stream, then the codebase value
chosen is the value that was returned by readAnnotation; otherwise, the codebase
value chosen is null.
This method then invokes ClassLoading.loadClass with the
chosen codebase value as the first argument, the name of the class described by
classDesc as the second argument, and the defaultLoader,
verifyCodebaseIntegrity, and verifierLoader values that were passed
to this stream's constructor as the third, fourth, and fifth arguments. If
ClassLoading.loadClass throws a ClassNotFoundException and the name
of the class described by classDesc equals the Java(TM) programming language
keyword for a primitive type or void, then this method returns the
Class corresponding to that primitive type or void (Integer.TYPE for int, Void.TYPE for void, and so forth).
Otherwise, if ClassLoading.loadClass throws an exception, this method throws
that exception, and if it returns normally, this method returns the Class
returned by ClassLoading.loadClass.
classDesc - the stream class descriptor to resolveIOException - if readAnnotation throws an IOException,
or if ClassLoading.loadClass throws a
MalformedURLExceptionClassNotFoundException - if readAnnotation or ClassLoading.loadClass
throws a ClassNotFoundExceptionNullPointerException - if classDesc is nullprotected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException
resolveClass in class ObjectInputStreamIOExceptionClassNotFoundExceptionprotected String readAnnotation(ObjectStreamClass desc) throws IOException, ClassNotFoundException
null) that was
written by a corresponding AnnotatedObjectOutputStream implementation.
AnnotatedObjectInputStream implements this method to just read the annotation
value from this stream using readUnshared, and if
readUnshared returns a non-null value that is not a
String, an InvalidObjectException is thrown.
A subclass can override this method to read the annotation from a different location.
null)IOException - if an I/O exception occurs reading the annotationClassNotFoundException - if a ClassNotFoundException occurs reading the
annotationCopyright © GigaSpaces.