/** * Reloads a class from classloader using same fully qualified class name * * @param cl classloader to be used * @param classType class object * @return * @throws InvocationException if class was not found in classloader */ static Class<?> reloadClass(ClassLoader cl, Class<?> classType) throws InvocationException { try { return cl.loadClass(classType.getName()); } catch (ClassNotFoundException e) { throw new InvocationException(e, "Unable to reload class {0} with class loader {1}, previously loaded with {2}", classType.getName(), cl, classType.getClassLoader()); } }
throw new InvocationException( "Unable to find method {0}({1}) in class {2} nor its superclasses or implemented interfaces", name, parameterTypes, classType.getName());
/** * Loads a class from classloader * * @param cl classloader to be used * @param classTypeName fully qualified class name * @return * @throws InvocationException if class was not found in classloader */ static Class<?> loadClass(ClassLoader cl, String classTypeName) throws InvocationException { try { return cl.loadClass(classTypeName); } catch (ClassNotFoundException e) { throw new InvocationException(e, "Unable to load class {0} with class loader {1}", classTypeName, cl); } }
return con.newInstance(parameters); } catch (NoSuchMethodException e) { throw new InvocationException(e, "Unable to invoke constructor {0}({1}) with parameters {3}", classType.getSimpleName(), parameterTypes, parameters); } catch (SecurityException e) { throw new InvocationException(e, "Unable to invoke constructor {0}({1}) with parameters {3}", classType.getSimpleName(), parameterTypes, parameters); } catch (InstantiationException e) { throw new InvocationException(e, "Unable to invoke constructor {0}({1}) with parameters {3}", classType.getSimpleName(), parameterTypes, parameters); } catch (IllegalAccessException e) { throw new InvocationException(e, "Unable to invoke constructor {0}({1}) with parameters {3}", classType.getSimpleName(), parameterTypes, parameters); } catch (IllegalArgumentException e) { throw new InvocationException(e, "Unable to invoke constructor {0}({1}) with parameters {3}", classType.getSimpleName(), parameterTypes, parameters); } catch (InvocationTargetException e) { throw new InvocationException(e, "Unable to invoke constructor {0}({1}) with parameters {3}", classType.getSimpleName(), parameterTypes, parameters);
return findMethod(name, parameterTypes).invoke(instance, parameters); } catch (IllegalAccessException e) { throw new InvocationException(e, "Unable to invoke {0}({1}) on object {2} with parameters {3}", name, parameterTypes, instance == null ? "" : instance.getClass().getName(), parameters); } catch (IllegalArgumentException e) { throw new InvocationException(e, "Unable to invoke {0}({1}) on object {2} with parameters {3}", name, parameterTypes, instance == null ? "" : instance.getClass().getName(), parameters); } catch (InvocationTargetException e) { throw new InvocationException(e, "Unable to invoke {0}({1}) on object {2} with parameters {3}", name, parameterTypes, instance == null ? "" : instance.getClass().getName(), parameters); } catch (SecurityException e) { throw new InvocationException(e, "Unable to invoke {0}({1}) on object {2} with parameters {3}", name, parameterTypes, instance == null ? "" : instance.getClass().getName(), parameters); } catch (InvocationException e) { throw new InvocationException(e, "Unable to invoke {0}({1}) on object {2} with parameters {3}", name, parameterTypes, instance == null ? "" : instance.getClass().getName(), parameters);