1 7 8 package javax.management.loading; 9 10 11 13 import java.security.AccessController ; 14 import java.security.Permission ; 15 import java.util.Iterator ; 16 import java.util.List ; 17 18 import javax.management.MBeanServer ; 20 import javax.management.MBeanServerFactory ; 21 import javax.management.loading.ClassLoaderRepository ; 22 23 import com.sun.jmx.trace.Trace; 24 25 45 @Deprecated 46 public class DefaultLoaderRepository { 47 48 private static final String dbgTag = "DefaultLoaderRepository"; 49 50 64 public static Class loadClass(String className) 65 throws ClassNotFoundException { 66 debug("loadClass",className); 67 return load(null, className); 68 } 69 70 86 public static Class loadClassWithout(ClassLoader loader, 87 String className) 88 throws ClassNotFoundException { 89 debug("loadClassWithout",className); 90 return load(loader, className); 91 } 92 93 private static Class load(ClassLoader without, String className) 94 throws ClassNotFoundException { 95 final List mbsList = MBeanServerFactory.findMBeanServer(null); 96 97 for (Iterator it = mbsList.iterator(); it.hasNext(); ) { 98 MBeanServer mbs = (MBeanServer ) it.next(); 99 ClassLoaderRepository clr = mbs.getClassLoaderRepository(); 100 try { 101 return clr.loadClassWithout(without, className); 102 } catch (ClassNotFoundException e) { 103 } 105 } 106 throw new ClassNotFoundException (className); 107 } 108 109 112 private static boolean isTraceOn() { 113 return Trace.isSelected(Trace.LEVEL_TRACE, Trace.INFO_MBEANSERVER); 114 } 115 116 private static void trace(String clz, String func, String info) { 117 Trace.send(Trace.LEVEL_TRACE, Trace.INFO_MBEANSERVER, clz, func, info); 118 } 119 120 private static void trace(String func, String info) { 121 trace(dbgTag, func, info); 122 } 123 124 private static boolean isDebugOn() { 125 return Trace.isSelected(Trace.LEVEL_DEBUG, Trace.INFO_MBEANSERVER); 126 } 127 128 private static void debug(String clz, String func, String info) { 129 Trace.send(Trace.LEVEL_DEBUG, Trace.INFO_MBEANSERVER, clz, func, info); 130 } 131 132 private static void debug(String func, String info) { 133 debug(dbgTag, func, info); 134 } 135 136 } 137 | Popular Tags |