01: package dalma.impl;
02:
03: import java.io.IOException;
04: import java.io.InputStream;
05: import java.io.ObjectInputStream;
06: import java.io.ObjectStreamClass;
07:
08: /**
09: * {@link ObjectInputStream} that uses a specific class loader.
10: *
11: * @author Kohsuke Kawaguchi
12: */
13: final class ObjectInputStreamEx extends ObjectInputStream {
14:
15: private final ClassLoader classLoader;
16:
17: public ObjectInputStreamEx(InputStream in, ClassLoader classLoader)
18: throws IOException {
19: super (in);
20: assert classLoader != null;
21: this .classLoader = classLoader;
22: }
23:
24: protected Class<?> resolveClass(ObjectStreamClass desc)
25: throws IOException, ClassNotFoundException {
26: String name = desc.getName();
27: return classLoader.loadClass(name);
28: }
29: }
|