1 package org.apache.turbine.util.pool;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.io.IOException;
20 import java.io.InputStream;
21 import java.io.ObjectInputStream;
22 import java.io.ObjectStreamClass;
23
24 /***
25 * A deserialization stream for a specific class loader context.
26 *
27 * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
28 * @version $Id: ObjectInputStreamForContext.java 264148 2005-08-29 14:21:04Z henning $
29 */
30 public class ObjectInputStreamForContext extends ObjectInputStream
31 {
32 /***
33 * The class loader of the context.
34 */
35 private ClassLoader classLoader;
36
37 /***
38 * Contructs a new object stream for a context.
39 *
40 * @param in the serialized input stream.
41 * @param loader the class loader of the context.
42 * @throws IOException on errors.
43 */
44 public ObjectInputStreamForContext(InputStream in,
45 ClassLoader loader)
46 throws IOException
47 {
48 super(in);
49 classLoader = loader;
50 }
51
52 protected Class resolveClass(ObjectStreamClass v)
53 throws IOException,
54 ClassNotFoundException
55 {
56 return classLoader == null ?
57 super.resolveClass(v) : classLoader.loadClass(v.getName());
58 }
59 }