1 24 package org.ofbiz.base.util; 25 26 import java.io.InputStream ; 27 import java.io.IOException ; 28 import java.io.ObjectStreamClass ; 29 import java.lang.reflect.Proxy ; 30 31 38 public class ObjectInputStream extends java.io.ObjectInputStream { 39 40 private ClassLoader classloader; 41 42 public ObjectInputStream(InputStream in, ClassLoader loader) throws IOException { 43 super(in); 44 this.classloader = loader; 45 } 46 47 50 protected Class resolveClass(ObjectStreamClass classDesc) throws IOException , ClassNotFoundException { 51 return ObjectType.loadClass(classDesc.getName(), classloader); 52 } 53 54 57 protected Class resolveProxyClass(String [] interfaces) throws IOException , ClassNotFoundException { 58 Class [] cinterfaces = new Class [interfaces.length]; 59 for (int i = 0; i < interfaces.length; i++) 60 cinterfaces[i] = classloader.loadClass(interfaces[i]); 61 62 try { 63 return Proxy.getProxyClass(classloader, cinterfaces); 64 } catch (IllegalArgumentException e) { 65 throw new ClassNotFoundException (null, e); 66 } 67 68 } 69 } | Popular Tags |