1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.geronimo.kernel;
18
19 import java.io.IOException;
20 import java.io.InputStream;
21 import java.io.ObjectInputStream;
22 import java.io.ObjectStreamClass;
23 import java.lang.reflect.Proxy;
24
25 /**
26 * @version $Rev: 392392 $ $Date: 2006-04-07 13:53:55 -0700 (Fri, 07 Apr 2006) $
27 */
28 public class ObjectInputStreamExt extends ObjectInputStream {
29
30 private ClassLoader classloader;
31
32 public ObjectInputStreamExt(InputStream in, ClassLoader loader) throws IOException {
33 super(in);
34 this.classloader = loader;
35 }
36
37 protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
38 return ClassLoading.loadClass(classDesc.getName(), classloader);
39 }
40
41 protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException {
42 Class[] cinterfaces = new Class[interfaces.length];
43 for (int i = 0; i < interfaces.length; i++)
44 cinterfaces[i] = classloader.loadClass(interfaces[i]);
45
46 try {
47 return Proxy.getProxyClass(classloader, cinterfaces);
48 } catch (IllegalArgumentException e) {
49 throw new ClassNotFoundException(null, e);
50 }
51 }
52
53 ClassLoader getClassloader() {
54 return classloader;
55 }
56
57 }