final ClassLoader classLoader) throws TeiidException {
Class<?> cls;
try {
cls = loadClass(className,classLoader);
} catch(Exception e) {
throw new TeiidException(e);
}
Constructor<?> ctor = null;
try {
ctor = cls.getDeclaredConstructor(argTypes);
} catch (NoSuchMethodException e) {
}
if (ctor == null && argTypes != null && argTypes.length > 0) {
List<Class<?>> argumentsClasses = Arrays.asList(argTypes);
List<Class<?>> argumentsClassList = convertArgumentClassesToPrimitives(argumentsClasses);
for (Constructor<?> possible : cls.getDeclaredConstructors()) {
if (argsMatch(argumentsClasses, argumentsClassList, possible.getParameterTypes())) {
ctor = possible;
break;
}
}
}
if (ctor == null) {
throw new TeiidException(className + " Args: " + Arrays.toString(argTypes)); //$NON-NLS-1$
}
try {
return ctor.newInstance(ctorObjs);
} catch (Exception e) {
throw new TeiidException(e);
}
}