/** * We load the report class by name, to be able to use third party report * formats. */ @SuppressWarnings("unchecked") private Class< ? extends Report> loadReportClass() throws ClassNotFoundException { return ( Class< ? extends Report> ) ClassUtils.loadClass(classLoader, reportClass); }
/** * We load the interpreter selector by a class name, to be able to use third * party interpreter selectors. */ @SuppressWarnings("unchecked") private Class< ? extends InterpreterSelector> loadInterpreterSelectorClass() throws ClassNotFoundException { return ( Class< ? extends InterpreterSelector> ) ClassUtils.loadClass(classLoader, interpreterSelectorClass); }
private static Class< ? > loadClass(String expectation) { try { return ClassUtils.loadClass(expectation); } catch (ClassNotFoundException ex) { LOG.trace(LOG_ERROR, ex); } return null; }
public static Class< ? > loadClass(String className) throws ClassNotFoundException { // Instead of the Thread.currentThread().getContextClassLoader() we are // using the current class classLoader, to be compatible with a OSGI // environment (mainly for the confluence plugin). For more information // see: https://wiki.eclipse.org/Context_Class_Loader_Enhancements or // http://njbartlett.name/2010/08/30/osgi-readiness-loading-classes.html return loadClass(ClassUtils.class.getClassLoader(), className); }
private DocumentRepository getRepository(List<String> definition) throws SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { Class<?> klass = ClassUtils.loadClass(definition.get(0)); Constructor<?> constructor = klass.getConstructor(String[].class); return (DocumentRepository) constructor.newInstance(new Object[]{args(definition)}); }
@Override public Object convert(String value) throws IllegalArgumentException, SecurityException, ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { List<String> parameters = toList(ClassUtils.escapeValues(value.split(";"))); Class< ? > klass = ClassUtils.loadClass(shift(parameters)); if (expectedType != null && ! expectedType.isAssignableFrom(klass)) { throw new IllegalArgumentException("Class " + expectedType.getName() + " is not assignable from" + klass .getName()); } if (parameters.size() == 0) { return klass.newInstance(); } String[] args = parameters.toArray(new String[parameters.size()]); Constructor< ? > constructor = klass.getConstructor(args.getClass()); return constructor.newInstance(new Object[] { args }); } }
public void setSystemValue(String value) { try { systemValue = ClassUtils.loadClass(value).newInstance(); } catch (Exception e) { systemValue = value; } } }
public static <C> C createInstanceFromClassNameWithArguments(ClassLoader classLoader, String classWithArguments, Class<C> expectedType) throws UndeclaredThrowableException { try { List<String> parameters = toList(escapeValues(classWithArguments.split(";"))); Class< ? > klass = ClassUtils.loadClass(classLoader, shift(parameters)); if ( ! expectedType.isAssignableFrom(klass)) { throw new IllegalArgumentException("Class " + expectedType.getName() + " is not assignable from " + klass .getName()); } if (parameters.size() == 0) { return expectedType.cast(klass.newInstance()); } String[] args = parameters.toArray(new String[parameters.size()]); Constructor< ? > constructor = klass.getConstructor(args.getClass()); return expectedType.cast(constructor.newInstance(new Object[] { args })); } catch (ClassNotFoundException e) { throw new UndeclaredThrowableException(e); } catch (InstantiationException e) { throw new UndeclaredThrowableException(e); } catch (IllegalAccessException e) { throw new UndeclaredThrowableException(e); } catch (NoSuchMethodException e) { throw new UndeclaredThrowableException(e); } catch (InvocationTargetException e) { throw new UndeclaredThrowableException(e); } }
public String thatConvertingToUses(String typeName) throws ClassNotFoundException { TypeConverter converter = TypeConversion.converterForType(ClassUtils.loadClass(typeName)); return converter.getClass().getSimpleName(); }
private static Class< ? > getClass(String typename) throws ClassNotFoundException { return ClassUtils.loadClass("info.novatec.testit.livingdoc.fixture.interpreter.CollectionResolutionFixture$" + NameUtils.toClassName(typename)); }
public void register(String converterName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { Class< ? > clazz = ClassUtils.loadClass(converterName); LivingDoc.register(( TypeConverter ) clazz.newInstance()); }
private static Class< ? > getClass(String typename) throws ClassNotFoundException { return ClassUtils.loadClass("info.novatec.testit.livingdoc.fixture.converter.TypeConversionFixture$" + NameUtils .toClassName(typename)); }