1 8 package org.codehaus.aspectwerkz.util; 9 10 import java.io.IOException ; 11 import java.io.InputStream ; 12 import java.io.ObjectInputStream ; 13 import java.io.ObjectStreamClass ; 14 import java.lang.reflect.Proxy ; 15 16 22 public class UnbrokenObjectInputStream extends ObjectInputStream { 23 24 30 public UnbrokenObjectInputStream() throws IOException , SecurityException { 31 super(); 32 } 33 34 40 public UnbrokenObjectInputStream(final InputStream in) throws IOException { 41 super(in); 42 } 43 44 48 protected Class resolveClass(final ObjectStreamClass desc) throws IOException , ClassNotFoundException { 49 try { 50 Class resolved = Class.forName(desc.getName(), false, Thread.currentThread().getContextClassLoader()); 51 return resolved; 52 } catch (ClassNotFoundException ex) { 53 return super.resolveClass(desc); 54 } 55 } 56 57 61 protected Class resolveProxyClass(String [] interfaces) throws IOException , ClassNotFoundException { 62 try { 63 Class [] classObjs = new Class [interfaces.length]; 64 for (int i = 0; i < interfaces.length; i++) { 65 classObjs[i] = Class.forName(interfaces[i], false, Thread.currentThread().getContextClassLoader()); 66 } 67 return Proxy.getProxyClass(Thread.currentThread().getContextClassLoader(), classObjs); 68 } catch (Exception e) { 69 e.printStackTrace(); 70 return super.resolveProxyClass(interfaces); 71 } 72 } 73 74 } 75 | Popular Tags |