1 22 package org.jboss.iiop; 23 24 import org.jboss.logging.Logger; 25 import org.jboss.proxy.compiler.IIOPStubCompiler; 26 27 35 public class StubClassLoader 36 extends ClassLoader 37 { 38 39 41 private static final Logger logger = 42 Logger.getLogger(StubClassLoader.class); 43 44 46 public StubClassLoader(ClassLoader parent) 47 { 48 super(parent); 49 } 50 51 53 protected Class findClass(String name) 54 throws ClassNotFoundException 55 { 56 logger.debug("findClass(" + name + ") called"); 57 if (name.endsWith("_Stub")) { 58 int start = name.lastIndexOf('.') + 1; 59 if (name.charAt(start) == '_') { 60 String pkg = name.substring(0, start); 61 String interfaceName = pkg + name.substring(start + 1, 62 name.length() - 5); 63 logger.debug("interface name " + interfaceName); 64 Class intf = loadClass(interfaceName); 65 logger.debug("loaded class " + interfaceName); 66 67 try { 68 byte[] code = IIOPStubCompiler.compile(intf, name); 69 70 logger.debug("compiled stub class for " + interfaceName); 71 Class clz = defineClass(name, code, 0, code.length); 72 logger.debug("defined stub class for " + interfaceName); 73 resolveClass(clz); 74 logger.debug("resolved stub class for " + interfaceName); 75 return clz; 76 } 77 catch (RuntimeException e) { 78 logger.debug("Exception generating IIOP stub " + name, e); 79 throw e; 80 } 81 } 82 } 83 throw new ClassNotFoundException (name); 84 } 85 86 } 87 | Popular Tags |