1 28 29 package com.caucho.vfs; 30 31 import java.io.IOException ; 32 import java.io.InputStream ; 33 import java.io.ObjectInputStream ; 34 import java.io.ObjectStreamClass ; 35 import java.lang.reflect.Proxy ; 36 37 40 public class ContextLoaderObjectInputStream extends ObjectInputStream { 41 44 public ContextLoaderObjectInputStream(InputStream is) 45 throws IOException 46 { 47 super(is); 48 } 49 50 protected Class resolveClass(ObjectStreamClass v) 51 throws IOException , ClassNotFoundException 52 { 53 String name = v.getName(); 54 55 Thread thread = Thread.currentThread(); 56 ClassLoader loader = thread.getContextClassLoader(); 57 58 return Class.forName(name, false, loader); 59 } 60 61 protected Class resolveProxyClass(String []interfaceNames) 62 throws IOException , ClassNotFoundException 63 { 64 Thread thread = Thread.currentThread(); 65 ClassLoader loader = thread.getContextClassLoader(); 66 67 Class []clArray = new Class [interfaceNames.length]; 68 69 for (int i = 0; i < interfaceNames.length; i++) { 70 clArray[i] = Class.forName(interfaceNames[i], false, loader); 71 } 72 73 return Proxy.getProxyClass(loader, clArray); 74 } 75 } 76 | Popular Tags |