1 17 package org.apache.ws.jaxme.util; 18 19 20 25 public class ClassLoader { 26 33 public static Class getClass(String pName) throws ClassNotFoundException { 34 try { 36 return Class.forName(pName); 37 } catch (ClassNotFoundException e) { 38 try { 40 java.lang.ClassLoader cl = Thread.currentThread().getContextClassLoader(); 41 if (cl == null) { 42 throw new ClassNotFoundException (pName); 43 } 44 return cl.loadClass(pName); 45 } catch (ClassNotFoundException f) { 46 throw e; 47 } 48 } 49 } 50 51 62 public static Class getClass(String pName, Class pAssignableTo) 63 throws ClassNotFoundException { 64 Class result = getClass(pName); 65 if (pAssignableTo != null && !pAssignableTo.isAssignableFrom(result)) { 66 throw new IllegalArgumentException ("The class " + result.getName() + 67 " is not implementing or extending " + 68 pAssignableTo.getName()); 69 } 70 return result; 71 } 72 } 73 | Popular Tags |