FileDocCategorySizeDatePackage
ReplicationStream.javaAPI DocApache Tomcat 6.0.144062Fri Jul 20 04:20:32 BST 2007org.apache.catalina.tribes.io

ReplicationStream

public final class ReplicationStream 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
author
Filip Hanik
version
$Revision: 467173 $, $Date: 2006-10-24 01:12:17 +0200 (mar., 24 oct. 2006) $

Fields Summary
private ClassLoader[]
classLoaders
The class loader we will use to resolve classes.
Constructors Summary
public ReplicationStream(InputStream stream, ClassLoader[] classLoaders)
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.classLoaders = classLoaders;
    
Methods Summary
public voidclose()

        this.classLoaders = null;
        super.close();
    
public java.lang.ClassfindExternalClass(java.lang.String name)

        ClassNotFoundException cnfe = null;
        for (int i=0; i<classLoaders.length; i++ ) {
            try {
                Class clazz = Class.forName(name, false, classLoaders[i]);
                return clazz;
            } catch ( ClassNotFoundException x ) {
                cnfe = x;
            } 
        }
        if ( cnfe != null ) throw cnfe;
        else throw new ClassNotFoundException(name);
    
public java.lang.ClassfindReplicationClass(java.lang.String name)

        Class clazz = Class.forName(name, false, getClass().getClassLoader());
        return clazz;
    
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

        String name = classDesc.getName();
        boolean tryRepFirst = name.startsWith("org.apache.catalina.tribes");
        try {
            try
            {
                if ( tryRepFirst ) return findReplicationClass(name);
                else return findExternalClass(name);
            }
            catch ( Exception x )
            {
                if ( tryRepFirst ) return findExternalClass(name);
                else return findReplicationClass(name);
            }
        } catch (ClassNotFoundException e) {
            return super.resolveClass(classDesc);
        }