Class<ConfigurationFactory> configurationFactoryClass = props.asClass(CONFIGURATION_FACTORY, ConfigurationFactory.class);
if (configurationFactoryClass != null) {
return configurationFactoryClass.newInstance();
}
} catch (ReflectiveOperationException ex) {
throw new ConfigurationException("Could not instantiate specified configuration factory class " + props.asString(CONFIGURATION_FACTORY, null), ex);
}
ServiceLoader<ConfigurationFactory> serviceLoader = ServiceLoader.load(ConfigurationFactory.class, classLoader);
try {
return Iterables.getOnlyElement(serviceLoader, new DefaultConfigurationFactory());
} catch (IllegalArgumentException ex) {
throw new ConfigurationException("Multiple possible configuration factories were found; please specify one with the '" + CONFIGURATION_FACTORY + "' property", ex);
}
}