public static <T> T getInstance(Class<T> expectedType, String className, Collection ctorObjs, Class defaultClass) throws ResourceException {
try {
if (className == null) {
if (defaultClass == null) {
throw new ResourceException("Neither class name or default class specified to create an instance"); //$NON-NLS-1$
}
return expectedType.cast(defaultClass.newInstance());
}
return expectedType.cast(ReflectionHelper.create(className, ctorObjs, Thread.currentThread().getContextClassLoader()));
} catch (TeiidException e) {
throw new ResourceException(e);
} catch (IllegalAccessException e) {
throw new ResourceException(e);
} catch(InstantiationException e) {
throw new ResourceException(e);
}
}