01: package org.apache.turbine.util.pool;
02:
03: /*
04: * Copyright 2001-2005 The Apache Software Foundation.
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License")
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
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: * The class loader of the context.
33: */
34: private ClassLoader classLoader;
35:
36: /**
37: * Contructs a new object stream for a context.
38: *
39: * @param in the serialized input stream.
40: * @param loader the class loader of the context.
41: * @throws IOException on errors.
42: */
43: public ObjectInputStreamForContext(InputStream in,
44: ClassLoader loader) throws IOException {
45: super (in);
46: classLoader = loader;
47: }
48:
49: protected Class resolveClass(ObjectStreamClass v)
50: throws IOException, ClassNotFoundException {
51: return classLoader == null ? super.resolveClass(v)
52: : classLoader.loadClass(v.getName());
53: }
54: }
|