1 13 package info.magnolia.cms.util; 14 15 import org.slf4j.Logger; 16 import org.slf4j.LoggerFactory; 17 18 19 24 public final class ClassUtil { 25 26 29 private static Logger log = LoggerFactory.getLogger(ClassUtil.class); 30 31 34 private ClassUtil() { 35 } 37 38 44 public static Class classForName(String className) throws ClassNotFoundException { 45 Class loadedClass; 46 try { 47 loadedClass = Class.forName(className); 48 } 49 catch (ClassNotFoundException e) { 50 loadedClass = Class.forName(className, true, Thread.currentThread().getContextClassLoader()); 51 } 52 return loadedClass; 53 } 54 55 63 public static Object newInstance(String className) throws InstantiationException , IllegalAccessException , 64 ClassNotFoundException { 65 return classForName(className).newInstance(); 66 } 67 } 68 | Popular Tags |