List of utility methods to do Class Load
Class> | loadClass(final String className) Loads the class with the given name, or null if it cannot be loaded. return loadClass(className, null);
|
Class | loadClass(final String className) load Class try { return (Class<T>) Thread.currentThread().getContextClassLoader().loadClass(className); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Unable to load class " + className); |
Class> | loadClass(final String className) load Class if (className == null) { return null; try { final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader != null) { try { final Class clazz = classLoader.loadClass(className); ... |
Class> | loadClass(final String className, final ClassLoader classLoader) Tries to load the class with the given name. try { final ClassLoader cl = classLoader == null ? Thread.currentThread().getContextClassLoader() : classLoader; return cl.loadClass(className); } catch (final ClassNotFoundException e) { return null; |
Class> | loadClass(final String className, final ClassLoader classLoader) Helper method to load a class. Class<?> cls = null; if (classLoader == null) { cls = Class.forName(className.trim()); } else { cls = Class.forName(className.trim(), true, classLoader); return cls; |
Class> | loadClass(final String clazz) Loads the given class using the context class loader Class<?> clazzObject; try { clazzObject = Thread.currentThread().getContextClassLoader().loadClass(clazz); } catch (final ClassNotFoundException e) { throw new RuntimeException("Unable to load " + clazz, e); return clazzObject; |
Class> | loadClass(final String fqcn) Load a root entity class or return null if it can't be loaded. try { return Thread.currentThread().getContextClassLoader().loadClass(fqcn); } catch (final ClassNotFoundException e) { return null; |
Object | loadClass(final String lclass) Utility method to dynamically load classes Object loadedClass = null; Class handlerClass = null; try { handlerClass = Class.forName(lclass); } catch (final NoClassDefFoundError e) { throw new RuntimeException("Cannot find class : " + lclass, e); } catch (final ClassNotFoundException e) { throw new RuntimeException("Cannot find class : " + lclass, e); ... |
Class> | loadClass(final String packageName, final String className) Rather than using the Class.forName mechanism first, this uses Thread.getContextClassLoader instead. return loadClass(toQualifiedClassName(packageName, className));
|
Class> | loadClass(String className) load Class Class<?> clazz = null; try { clazz = Thread.currentThread().getContextClassLoader().loadClass(className); } catch (ClassNotFoundException e) { throw new ClassNotFoundException(); } catch (Exception e) { throw new Exception(e); if (clazz == null) { clazz = Class.forName(className); return clazz; |