CustomObjectInputStreampublic 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. |
Fields Summary |
---|
private ClassLoader | classLoaderThe class loader we will use to resolve classes. |
Constructors Summary |
---|
public CustomObjectInputStream(InputStream stream, ClassLoader classLoader)Construct a new instance of CustomObjectInputStream
super(stream);
this.classLoader = classLoader;
|
Methods Summary |
---|
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.
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.Class | resolveProxyClass(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);
}
|
|