1 28 29 package org.objectweb.util.explorer.core.common.lib; 30 31 32 import java.io.InputStream ; 33 import java.net.URL ; 34 import java.net.URLClassLoader ; 35 36 44 public class ClassResolver 45 { 46 47 48 protected static URLClassLoader current_ = 49 (URLClassLoader ) Thread.currentThread().getContextClassLoader(); 50 51 55 public static void addContext(URL [] urls) { 56 if (urls != null) { 57 URLClassLoader newCL = URLClassLoader.newInstance(urls, current_); 58 current_ = newCL; 59 Thread.currentThread().setContextClassLoader(current_); 60 } 61 } 62 63 70 public static Class resolve(String className) 71 throws ClassNotFoundException { 72 return Class.forName(className, true, current_); 73 } 74 75 80 public static URL getResource(String name) { 81 return current_.getResource(name); 82 } 83 84 89 public static InputStream getResourceAsStream(String name) { 90 return current_.getResourceAsStream(name); 91 } 92 93 } 94 | Popular Tags |