1 26 27 package org.objectweb.util.browser.core.common; 28 29 30 import java.io.InputStream ; 31 import java.net.URL ; 32 import java.net.URLClassLoader ; 33 34 40 public class ClassResolver { 41 42 43 protected static URLClassLoader current_ = 44 (URLClassLoader ) Thread.currentThread().getContextClassLoader(); 45 46 50 public static void addContext(URL [] urls) { 51 if (urls != null) { 52 URLClassLoader newCL = URLClassLoader.newInstance(urls, current_); 53 current_ = newCL; 54 Thread.currentThread().setContextClassLoader(current_); 55 } 56 } 57 58 65 public static Class resolve(String className) 66 throws ClassNotFoundException { 67 return Class.forName(className, true, current_); 68 } 69 70 75 public static URL getResource(String name) { 76 return current_.getResource(name); 77 } 78 79 84 public static InputStream getResourceAsStream(String name) { 85 return current_.getResourceAsStream(name); 86 } 87 88 } 89 | Popular Tags |