1 28 29 30 package org.objectweb.corba.runtime; 31 32 36 public class TheClassLoader 37 { 38 static private String _class_name = "TheClassLoader"; 40 static private org.objectweb.util.launcher.XBootClassLoader _xloader; 41 42 46 static private void 47 init() 48 { 49 _xloader = (org.objectweb.util.launcher.XBootClassLoader)Thread.currentThread().getContextClassLoader(); 50 } 51 52 static private org.objectweb.util.launcher.XBootClassLoader 53 getXLoader() 54 { 55 if (_xloader==null) { 56 init(); 57 } 58 59 return _xloader; 60 } 61 62 static private Object 63 callStaticClassMethod(String entrypt, 64 Class [] argt, 65 Object [] argv) 66 throws java.lang.ClassNotFoundException , 67 java.lang.NoSuchMethodException , 68 java.lang.reflect.InvocationTargetException , 69 java.lang.IllegalAccessException 70 { 71 int idx = entrypt.lastIndexOf('.'); 73 java.lang.String class_name = entrypt.substring(0, idx); 74 java.lang.String method_name = entrypt.substring(idx+1); 75 76 80 Class the_class = Class.forName(class_name); 82 83 java.lang.reflect.Method the_method = the_class.getMethod(method_name, argt); 85 86 Object result = the_method.invoke(null, argv); 88 89 return result; 91 } 92 93 97 static public void 98 addResource(String path) 99 { 100 final String opname = "addResource"; 101 String url_str = path; 104 if (!url_str.startsWith("file:")) { 105 url_str = "file:"+url_str; 106 } 107 108 java.net.URL url = null; 109 try { 110 url = new java.net.URL (url_str); 111 } catch (java.net.MalformedURLException ex) { 112 TheLogger.error(_class_name, opname, "FAILED (wrong URL format)", ex); 115 } 116 117 final String msg = "Adding URL: "+url.toString(); 119 TheLogger.debug(_class_name, opname, msg); 120 getXLoader().addURL(url); 121 } 122 123 static public Object 124 newInstance(String entrypt) 125 { 126 return newInstance(entrypt, new Class [0], new Object [0]); 127 } 128 129 static public Object 130 newInstance(String entrypt, Class [] argt, Object [] argv) 131 { 132 try { 133 return callStaticClassMethod(entrypt, argt, argv); 134 } catch (Exception ex) { 135 final String opname = "newInstance"; 136 TheLogger.debug(_class_name, opname, "IGNORE", ex); 137 return null; 138 } 139 } 140 } 141 | Popular Tags |