Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.remoting.loading
Class ObjectInputStreamWithClassLoader

    java.lang.Object
      java.io.InputStream
          java.io.ObjectInputStream
              org.jboss.remoting.loading.ObjectInputStreamWithClassLoader

All Implemented Interfaces:
  java.io.Closeable, java.io.DataInput, java.io.ObjectInput, java.io.ObjectStreamConstants

    public class ObjectInputStreamWithClassLoader

extends java.io.ObjectInputStream

ObjectInputStreamWithClassLoader

Version:
  $Revision: 2359 $
Author:
  Jeff Haynie, Tom Elrod

Nested Class Summary

Nested classes/interfaces inherited from class java.io.ObjectInputStream
`java.io.ObjectInputStream.GetField`

Field Summary
`protected static java.lang.reflect.Method` | `clearMethod`
`protected static org.jboss.logging.Logger` | `log`

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, 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
`ObjectInputStreamWithClassLoader(java.io.InputStream in, java.lang.ClassLoader cl)` Create an ObjectInputStream that reads from the specified InputStream.

Method Summary
`void` | `clearCache()`
`java.lang.ClassLoader` | `getClassLoader()` Gets the pluggable classloader that will be used for classloading when deserializing objects.
`protected java.lang.Class` | `resolveClass(java.io.ObjectStreamClass v)` Load the local class equivalent of the specified stream class description.
`protected java.lang.Class` | `resolveProxyClass(java.lang.String[] interfaces)` Returns a proxy class that implements the interfaces named in a proxy class descriptor; subclasses may implement this method to read custom data from the stream along with the descriptors for dynamic proxy classes, allowing them to use an alternate loading mechanism for the interfaces and the proxy class.
`void` | `setClassLoader(java.lang.ClassLoader cl)` Set the classloader that the stream will used when deserializing class.

Methods inherited from class java.io.ObjectInputStream
`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, skipBytes`

Methods inherited from class java.io.InputStream
`mark, markSupported, read, reset, skip`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface java.io.ObjectInput
`read, skip`

Field Detail

### clearMethod

    protected static java.lang.reflect.Method clearMethod

### log

    protected static final org.jboss.logging.Logger log

Constructor Detail

### ObjectInputStreamWithClassLoader

    public ObjectInputStreamWithClassLoader(java.io.InputStream in,
                                            java.lang.ClassLoader cl)
                                     throws java.io.IOException,
                                            java.io.StreamCorruptedException

  Create an ObjectInputStream that reads from the specified InputStream. The stream header containing the magic number and version number are read from the stream and verified. This method will block until the corresponding ObjectOutputStream has written and flushed the header.

  Parameters:
    `in` - the underlying `InputStream` from which to read
  Throws:
    `java.io.StreamCorruptedException` - The version or magic number are incorrect.
    `java.io.IOException` - An exception occurred in the underlying stream.

Method Detail

### setClassLoader

    public void setClassLoader(java.lang.ClassLoader cl)

  Set the classloader that the stream will used when deserializing class. This will allow plugging in of classloaders based on invocation context.

  Parameters:
    `cl` -

### getClassLoader

    public java.lang.ClassLoader getClassLoader()

  Gets the pluggable classloader that will be used for classloading when deserializing objects.

  Returns:

### clearCache

    public void clearCache()

### resolveClass

    protected java.lang.Class resolveClass(java.io.ObjectStreamClass v)
                                    throws java.io.IOException,
                                           java.lang.ClassNotFoundException

  Load the local class equivalent of the specified stream class description.

  Subclasses may implement this method to allow classes to be fetched from an alternate source.

  The corresponding method in ObjectOutputStream is annotateClass. This method will be invoked only once for each unique class in the stream. This method can be implemented by subclasses to use an alternate loading mechanism but must return a Class object. Once returned, the serialVersionUID of the class is compared to the serialVersionUID of the serialized class. If there is a mismatch, the deserialization fails and an exception is raised.

  By default the class name is resolved relative to the class that called readObject.

  Will use the classloader explicitly set if it exists. If it does not exist, will used its default classloader (that loader this instance).

  Overrides:
    `resolveClass` in class `java.io.ObjectInputStream`
  Parameters:
    `v` - an instance of class ObjectStreamClass
  Returns:
    a Class object corresponding to `v`
  Throws:
    `java.io.IOException` - Any of the usual Input/Output exceptions.
    `java.lang.ClassNotFoundException` - If class of a serialized object cannot be found.

### resolveProxyClass

    protected java.lang.Class resolveProxyClass(java.lang.String[] interfaces)
                                         throws java.io.IOException,
                                                java.lang.ClassNotFoundException

  Returns a proxy class that implements the interfaces named in a proxy class descriptor; subclasses may implement this method to read custom data from the stream along with the descriptors for dynamic proxy classes, allowing them to use an alternate loading mechanism for the interfaces and the proxy class.

  This method is called exactly once for each unique proxy class descriptor in the stream.

  The corresponding method in `ObjectOutputStream` is `annotateProxyClass`. For a given subclass of `ObjectInputStream` that overrides this method, the `annotateProxyClass` method in the corresponding subclass of `ObjectOutputStream` must write any data or objects read by this method.

  The default implementation of this method in `ObjectInputStream` returns the result of calling `Proxy.getProxyClass` with the list of `Class` objects for the interfaces that are named in the `interfaces` parameter. The `Class` object for each interface name `i` is the value returned by calling

           Class.forName(i, false, loader)

  where `loader` is that of the first non-null class loader up the execution stack, or `null` if no non-null class loaders are on the stack (the same class loader choice used by the `resolveClass` method). This same value of `loader` is also the class loader passed to `Proxy.getProxyClass`. If `Proxy.getProxyClass` throws an `IllegalArgumentException`, `resolveProxyClass` will throw a `ClassNotFoundException` containing the `IllegalArgumentException`.

  Overrides:
    `resolveProxyClass` in class `java.io.ObjectInputStream`
  Parameters:
    `interfaces` - the list of interface names that were deserialized in the proxy class descriptor
  Returns:
    a proxy class for the specified interfaces
  Throws:
    `java.io.IOException` - any exception thrown by the underlying `InputStream`
    `java.lang.ClassNotFoundException` - if the proxy class or any of the named interfaces could not be found
  Since:
    1.3
  See Also:
    `ObjectOutputStream.annotateProxyClass(java.lang.Class)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright ? 1998-2005 JBoss Inc . All Rights Reserved.