ReplicationStreampublic 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. |
Fields Summary |
---|
private ClassLoader[] | classLoadersThe class loader we will use to resolve classes. |
Constructors Summary |
---|
public ReplicationStream(InputStream stream, ClassLoader[] classLoaders)Construct a new instance of CustomObjectInputStream
super(stream);
this.classLoaders = classLoaders;
|
Methods Summary |
---|
public void | close()
this.classLoaders = null;
super.close();
| public java.lang.Class | findExternalClass(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.Class | findReplicationClass(java.lang.String name)
Class clazz = Class.forName(name, false, getClass().getClassLoader());
return clazz;
| public java.lang.Class | resolveClass(java.io.ObjectStreamClass classDesc)Load the local class equivalent of the specified stream class
description, by using the class loader assigned to this Context.
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);
}
|
|