Top Description Fields Constructors Methods
org.apache.commons.io.input

public Class ClassLoaderObjectInputStream

extends ObjectInputStream
Class Inheritance
Imports
java.io.IOException, .InputStream, .ObjectInputStream, .ObjectStreamClass, .StreamCorruptedException

A special ObjectInputStream that loads a class based on a specified ClassLoader rather than the system default.

This is useful in dynamic container environments.

Author
Paul Hammant
Since
Commons IO 1.1
Version
$Id: ClassLoaderObjectInputStream.java 437567 2006-08-28 06:39:07Z bayard $

Field Summary

Modifier and TypeField and Description
private ClassLoader
classLoader

The class loader to use.

Constructor Summary

AccessConstructor and Description
public
ClassLoaderObjectInputStream(ClassLoader
the ClassLoader from which classes should be loaded
classLoader
,
InputStream
the InputStream to work on
inputStream
)

Constructs a new ClassLoaderObjectInputStream.

Method Summary

Modifier and TypeMethod and Description
protected Class<T>

Returns:

the Class object described by the ObjectStreamClass
resolveClass
(ObjectStreamClass
descriptor of the class
objectStreamClass
)

Overrides java.io.ObjectInputStream.resolveClass.

Resolve a class specified by the descriptor using the specified ClassLoader or the super ClassLoader.
Inherited from java.io.ObjectInputStream:
availableclosedefaultReadObjectenableResolveObjectgetObjectInputFilterreadreadreadBooleanreadBytereadCharreadClassDescriptorreadDoublereadFieldsreadFloatreadFullyreadFullyreadIntreadLinereadLongreadObjectreadObjectOverridereadShortreadStreamHeaderreadUnsharedreadUnsignedBytereadUnsignedShortreadUTFregisterValidationresolveObjectresolveProxyClasssetObjectInputFilterskipBytes

Field Detail

classLoaderback to summary
private ClassLoader classLoader

The class loader to use.

Constructor Detail

ClassLoaderObjectInputStreamback to summary
public ClassLoaderObjectInputStream(ClassLoader classLoader, InputStream inputStream) throws IOException, StreamCorruptedException

Constructs a new ClassLoaderObjectInputStream.

Parameters
classLoader:ClassLoader

the ClassLoader from which classes should be loaded

inputStream:InputStream

the InputStream to work on

Exceptions
IOException:
in case of an I/O error
StreamCorruptedException:
if the stream is corrupted

Method Detail

resolveClassback to summary
protected Class<T> resolveClass(ObjectStreamClass objectStreamClass) throws IOException, ClassNotFoundException

Overrides java.io.ObjectInputStream.resolveClass.

Resolve a class specified by the descriptor using the specified ClassLoader or the super ClassLoader.

Parameters
objectStreamClass:ObjectStreamClass

descriptor of the class

Returns:Class<T>

the Class object described by the ObjectStreamClass

Exceptions
IOException:
in case of an I/O error
ClassNotFoundException:
if the Class cannot be found