Class factoryClass = RequestUtils.applicationClass(classname);
Object factory = factoryClass.newInstance();
return (ComponentDefinitionsFactory) factory;
} catch (ClassCastException ex) { // Bad classname
throw new DefinitionsFactoryException(
"Error - createDefinitionsFactory : Factory class '"
+ classname
+ " must implement 'DefinitionsFactory'.",
ex);
} catch (ClassNotFoundException ex) { // Bad classname
throw new DefinitionsFactoryException(
"Error - createDefinitionsFactory : Bad class name '"
+ classname
+ "'.",
ex);
} catch (InstantiationException ex) { // Bad constructor or error
throw new DefinitionsFactoryException(ex);
} catch (IllegalAccessException ex) {
throw new DefinitionsFactoryException(ex);
}
}