ResourceNameIterator it = nameDiscoverers.findResourceNames(mySpi.getName());
ResourceClassIterator services =
new DiscoverClasses(loaders).findResourceClasses(it);
EngineConfigurationFactory factory = null;
while (factory == null && services.hasNext()) {
Class service = services.nextResourceClass().loadClass();
factory = newFactory(service, newFactoryParamTypes, params);
}
if (factory == null) {
try {
factory = EngineConfigurationFactoryServlet.newFactory(obj);
} catch (RuntimeException e) {
log.warn(Messages.getMessage("engineConfigInvokeNewFactory",
EngineConfigurationFactoryServlet.class.getName(),
requiredMethod), e);
}
if (factory == null) {
try {
// should NEVER return null.
factory = EngineConfigurationFactoryDefault.newFactory(obj);
} catch (RuntimeException e) {
log.warn(Messages.getMessage("engineConfigInvokeNewFactory",
EngineConfigurationFactoryDefault.class.getName(),
requiredMethod), e);
}
}
}
if (factory != null) {
if(log.isDebugEnabled())
log.debug(Messages.getMessage("engineFactory", factory.getClass().getName()));
} else {
log.error(Messages.getMessage("engineConfigFactoryMissing"));
// we should be throwing an exception here,
//
// but again, requires more refactoring than we want to swallow