1 22 package org.jboss.mx.server; 23 24 25 import java.io.InputStream ; 26 import java.io.ObjectInputStream ; 27 import java.io.ObjectStreamClass ; 28 import java.io.IOException ; 29 30 import java.lang.reflect.Proxy ; 31 32 43 44 45 public class ObjectInputStreamWithClassLoader 46 extends ObjectInputStream { 47 48 52 ClassLoader cl; 53 54 55 56 57 61 62 63 69 public ObjectInputStreamWithClassLoader(InputStream in, ClassLoader cl) 70 throws IOException { 71 72 super(in); 73 74 this.cl = cl; 75 } 76 77 78 79 80 84 85 86 96 protected Class resolveClass(ObjectStreamClass osc) 97 throws IOException , ClassNotFoundException { 98 99 return cl.loadClass(osc.getName()); 100 } 101 102 protected Class resolveProxyClass( String [] interfaces ) 103 throws IOException , ClassNotFoundException { 104 105 Class [] interfacesClass = new Class [interfaces.length]; 106 for( int i=0; i< interfaces.length; i++ ) 107 { 108 interfacesClass[i] = Class.forName(interfaces[i], false, cl); 109 } 110 111 return Proxy.getProxyClass(cl, interfacesClass); 112 } 113 } 114 115 116 117 118 | Popular Tags |