01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.openejb.client;
17:
18: import java.io.IOException;
19: import java.io.InputStream;
20: import java.io.ObjectInputStream;
21: import java.io.ObjectStreamClass;
22: import java.lang.reflect.Proxy;
23:
24: /**
25: * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 $
26: */
27: public class EjbObjectInputStream extends ObjectInputStream {
28:
29: public EjbObjectInputStream(InputStream in) throws IOException {
30: super (in);
31: }
32:
33: protected Class resolveClass(ObjectStreamClass classDesc)
34: throws IOException, ClassNotFoundException {
35: return Class.forName(classDesc.getName(), false,
36: getClassloader());
37: }
38:
39: protected Class resolveProxyClass(String[] interfaces)
40: throws IOException, ClassNotFoundException {
41: Class[] cinterfaces = new Class[interfaces.length];
42: for (int i = 0; i < interfaces.length; i++)
43: cinterfaces[i] = getClassloader().loadClass(interfaces[i]);
44:
45: try {
46: return Proxy.getProxyClass(getClassloader(), cinterfaces);
47: } catch (IllegalArgumentException e) {
48: throw new ClassNotFoundException(null, e);
49: }
50: }
51:
52: ClassLoader getClassloader() {
53: return Thread.currentThread().getContextClassLoader();
54: }
55:
56: }
|