1 26 27 package org.objectweb.ccm.util; 28 29 37 38 public class URLClassLoader 39 extends java.net.URLClassLoader 40 { 41 47 53 56 public 57 URLClassLoader() 58 { 59 super(new java.net.URL [0], Thread.currentThread().getContextClassLoader()); 60 } 61 62 67 public 68 URLClassLoader(java.net.URL urls[]) 69 { 70 super(urls, Thread.currentThread().getContextClassLoader()); 71 } 72 73 79 85 90 public void 91 addURL(java.net.URL url) 92 { 93 super.addURL(url); 94 } 95 96 104 public Object 105 callStaticClassMethod(String entrypt, 106 Object [] args) 107 throws java.lang.ClassNotFoundException , 108 java.lang.NoSuchMethodException , 109 java.lang.reflect.InvocationTargetException , 110 java.lang.IllegalAccessException 111 { 112 int idx = entrypt.lastIndexOf('.'); 114 java.lang.String class_name = entrypt.substring(0, idx); 115 java.lang.String method_name = entrypt.substring(idx+1); 116 117 java.lang.Class theClass = super.loadClass(class_name); 119 120 java.lang.reflect.Method theMethod = theClass.getMethod(method_name, new java.lang.Class [0]); 122 123 try 124 { 125 return theMethod.invoke(null, args); 127 } 128 catch(java.lang.NullPointerException exc) 129 { 130 throw new java.lang.NoSuchMethodException (entrypt + " is not a static method!!!"); 131 } 132 } 133 } 134 | Popular Tags |