1 23 package com.sun.enterprise.iiop; 24 25 import java.io.*; 26 27 public class HandleDelegateClassLoader 28 extends ClassLoader 29 { 30 31 public HandleDelegateClassLoader() { 32 super(); 33 } 34 35 protected Class findClass(String name) 36 throws ClassNotFoundException 37 { 38 42 Class c =Thread.currentThread().getContextClassLoader().loadClass(name); 43 44 return c; 45 } 46 47 protected Class loadClass(String name, boolean resolve) 48 throws ClassNotFoundException 49 { 50 if (!name.equals("com.sun.enterprise.iiop.IIOPHandleDelegate")) { 51 return super.loadClass(name, resolve); 52 } 53 54 Class handleDelClass = findLoadedClass(name); 55 if (handleDelClass != null) { 56 return handleDelClass; 57 } 58 59 try { 60 ClassLoader resCl = Thread.currentThread().getContextClassLoader(); 62 if (Thread.currentThread().getContextClassLoader() == null) { 63 resCl = getSystemClassLoader(); 64 } 65 InputStream is = resCl.getResourceAsStream("com/sun/enterprise/iiop/IIOPHandleDelegate.class"); 66 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 67 68 byte[] buf = new byte[4096]; int nread = 0; 70 while ( (nread = is.read(buf, 0, buf.length)) != -1 ) { 71 baos.write(buf, 0, nread); 72 } 73 baos.close(); 74 is.close(); 75 76 byte[] buf2 = baos.toByteArray(); 77 78 handleDelClass = defineClass( 79 "com.sun.enterprise.iiop.IIOPHandleDelegate", 80 buf2, 0, buf2.length); 81 82 } catch ( Exception ex ) { 83 throw (ClassNotFoundException )new ClassNotFoundException (ex.getMessage()).initCause(ex); 84 } 85 86 if (resolve) { 87 resolveClass(handleDelClass); 88 } 89 90 return handleDelClass; 91 } 92 } 93 | Popular Tags |