FileDocCategorySizeDatePackage
CustomObjectInputStream.javaAPI DocApache Tomcat 6.0.143566Fri Jul 20 04:20:32 BST 2007org.apache.catalina.util

CustomObjectInputStream

public final class CustomObjectInputStream extends ObjectInputStream
Custom subclass of ObjectInputStream that loads from the class loader for this web application. This allows classes defined only with the web application to be found correctly.
author
Craig R. McClanahan
author
Bip Thelin
version
$Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $

Fields Summary
private ClassLoader
classLoader
The class loader we will use to resolve classes.
Constructors Summary
public CustomObjectInputStream(InputStream stream, ClassLoader classLoader)
Construct a new instance of CustomObjectInputStream

param
stream The input stream we will read from
param
classLoader The class loader used to instantiate objects
exception
IOException if an input/output error occurs



                                        
      
                                    
          

        super(stream);
        this.classLoader = classLoader;
    
Methods Summary
public java.lang.ClassresolveClass(java.io.ObjectStreamClass classDesc)
Load the local class equivalent of the specified stream class description, by using the class loader assigned to this Context.

param
classDesc Class description from the input stream
exception
ClassNotFoundException if this class cannot be found
exception
IOException if an input/output error occurs

        try {
            return Class.forName(classDesc.getName(), false, classLoader);
        } catch (ClassNotFoundException e) {
            // Try also the superclass because of primitive types
            return super.resolveClass(classDesc);
        }
    
protected java.lang.ClassresolveProxyClass(java.lang.String[] interfaces)
Return a proxy class that implements the interfaces named in a proxy class descriptor. Do this using the class loader assigned to this Context.


        Class[] cinterfaces = new Class[interfaces.length];
        for (int i = 0; i < interfaces.length; i++)
            cinterfaces[i] = classLoader.loadClass(interfaces[i]);

        try {
            return Proxy.getProxyClass(classLoader, cinterfaces);
        } catch (IllegalArgumentException e) {
            throw new ClassNotFoundException(null, e);
        }