}
public SGFactory getSGFactory() throws SAXException {
final String mName = "getSGFactory";
log.finest(mName, "->");
SGFactoryChain chain = newSGFactoryChain(getGenerator());
log.finest(mName, "Created instance of " + chain.getClass().getName());
for (Iterator iter = sgFactoryChains.iterator(); iter.hasNext(); ) {
Class c = (Class) iter.next();
log.finest(mName, "Adding instance of " + c.getName());
Object o;
try {
Constructor con = c.getConstructor(new Class[]{SGFactoryChain.class});
o = con.newInstance(new Object[]{chain});
} catch (NoSuchMethodException e) {
throw new SAXException("The SGFactoryChain class " + c.getName() +
" has no constructor taking the backing chain as an argument.");
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
String msg = "Failed to invoke the constructor of class " + c.getName() +
" with an argument of type " + chain.getClass().getName() +
": " + t.getClass().getName() + ", " + t.getMessage();
if (t instanceof Exception) {
throw new SAXException(msg, (Exception) t);
} else {
throw new SAXException(msg, e);
}
} catch (Exception e) {
throw new SAXException("Failed to invoke the constructor of class " + c.getName() +
" with an argument of type " + chain.getClass().getName() +
": " + e.getClass().getName() + ", " + e.getMessage(), e);
}
chain = (SGFactoryChain) o;
}
SGFactory result = new SGFactoryImpl(chain);