1 22 package org.jboss.test.util; 23 24 import java.net.MalformedURLException ; 25 26 import java.rmi.server.RMIClassLoader ; 27 import java.rmi.server.RMIClassLoaderSpi ; 28 import java.util.Arrays ; 29 import java.util.Collection ; 30 31 import org.jboss.logging.Logger; 32 33 39 public class LoggingRMIClassLoader 40 extends RMIClassLoaderSpi 41 { 42 private static final Logger log = Logger.getLogger(LoggingRMIClassLoader.class); 43 44 46 49 RMIClassLoaderSpi delegate = RMIClassLoader.getDefaultProviderInstance(); 50 51 53 56 public LoggingRMIClassLoader() 57 { 58 } 59 60 62 public Class loadProxyClass(String codebase, String [] interfaces, ClassLoader cl) 63 throws MalformedURLException , ClassNotFoundException 64 { 65 Collection c = null; 66 try 67 { 68 if (interfaces != null) 69 c = Arrays.asList(interfaces); 70 Class result = delegate.loadProxyClass(codebase, interfaces, cl); 71 log.debug("loadClass: codebase=" + codebase + " interfaces=" + c + " cl=" + cl + " result=" + result); 72 return result; 73 } 74 catch (MalformedURLException e) 75 { 76 log.debug("loadClass: codebase=" + codebase + " interfaces=" + c + " cl=" + cl, e); 77 throw e; 78 } 79 catch (ClassNotFoundException e) 80 { 81 log.debug("loadClass: codebase=" + codebase + " interfaces=" + c + " cl=" + cl, e); 82 throw e; 83 } 84 } 85 86 public Class loadClass(String codebase, String name, ClassLoader cl) 87 throws MalformedURLException , ClassNotFoundException 88 { 89 try 90 { 91 Class result = delegate.loadClass(codebase, name, cl); 92 log.debug("loadClass: codebase=" + codebase + " name=" + name + " cl=" + cl + " result=" + result); 93 return result; 94 } 95 catch (MalformedURLException e) 96 { 97 log.debug("loadClass: codebase=" + codebase + " name=" + name + " cl=" + cl, e); 98 throw e; 99 } 100 catch (ClassNotFoundException e) 101 { 102 log.debug("loadClass: codebase=" + codebase + " name=" + name + " cl=" + cl, e); 103 throw e; 104 } 105 } 106 107 public ClassLoader getClassLoader(String codebase) 108 throws MalformedURLException 109 { 110 try 111 { 112 ClassLoader result = delegate.getClassLoader(codebase); 113 log.debug("getClassLoader: codebase=" + codebase + " result=" + result); 114 return result; 115 } 116 catch (MalformedURLException e) 117 { 118 log.debug("getClassLoader: codebase=" + codebase, e); 119 throw e; 120 } 121 } 122 123 public String getClassAnnotation(Class clazz) 124 { 125 String result = delegate.getClassAnnotation(clazz); 126 log.debug("getClassAnnotation: class=" + clazz + " result=" + result); 127 return result; 128 } 129 } 130 | Popular Tags |