org.apache.commons.io.input

Class ClassLoaderObjectInputStream


public class ClassLoaderObjectInputStream
extends ObjectInputStream

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

This is useful in dynamic container environments.

Version:
$Id: ClassLoaderObjectInputStream.java 369075 2006-01-14 18:23:42Z scolebourne $
Author:
Paul Hammant
Since:
Commons IO 1.1

Field Summary

private ClassLoader
classLoader
The class loader to use.

Constructor Summary

ClassLoaderObjectInputStream(ClassLoader classLoader, InputStream inputStream)
Constructs a new ClassLoaderObjectInputStream.

Method Summary

protected Class
resolveClass(ObjectStreamClass objectStreamClass)
Resolve a class specified by the descriptor using the specified ClassLoader or the super ClassLoader.

Field Details

classLoader

private ClassLoader classLoader
The class loader to use.

Constructor Details

ClassLoaderObjectInputStream

public ClassLoaderObjectInputStream(ClassLoader classLoader,
                                    InputStream inputStream)
            throws IOException,
                   StreamCorruptedException
Constructs a new ClassLoaderObjectInputStream.
Parameters:
classLoader - the ClassLoader from which classes should be loaded
inputStream - the InputStream to work on

Method Details

resolveClass

protected Class resolveClass(ObjectStreamClass objectStreamClass)
            throws IOException,
                   ClassNotFoundException
Resolve a class specified by the descriptor using the specified ClassLoader or the super ClassLoader.
Parameters:
objectStreamClass - descriptor of the class
Returns:
the Class object described by the ObjectStreamClass