1 17 18 21 package org.quartz.simpl; 22 23 import org.quartz.spi.ClassLoadHelper; 24 25 import java.lang.reflect.AccessibleObject ; 26 import java.lang.reflect.Method ; 27 import java.net.URL ; 28 import java.io.InputStream ; 29 30 40 public class SimpleClassLoadHelper implements ClassLoadHelper { 41 42 49 50 55 public void initialize() { 56 } 57 58 61 public Class loadClass(String name) throws ClassNotFoundException { 62 return Class.forName(name); 63 } 64 65 71 public URL getResource(String name) { 72 return getClassLoader().getResource(name); 73 } 74 75 81 public InputStream getResourceAsStream(String name) { 82 return getClassLoader().getResourceAsStream(name); 83 } 84 85 private ClassLoader getClassLoader() { 86 try { 90 ClassLoader cl = this.getClass().getClassLoader(); 92 Method mthd = ClassLoader .class.getDeclaredMethod( 95 "getCallerClassLoader", new Class [0]); 96 AccessibleObject.setAccessible(new AccessibleObject [] {mthd}, true); 98 return (ClassLoader )mthd.invoke(cl, new Object [0]); 100 } catch (Exception all) { 101 return this.getClass().getClassLoader(); 103 } 104 } 105 106 } 107 | Popular Tags |