String resource = entry.getKey();
Class<? extends BeanDefinitionReader> readerClass = entry.getValue();
if (!readerInstanceCache.containsKey(readerClass)) {
try {
// Instantiate the specified BeanDefinitionReader
BeanDefinitionReader readerInstance =
readerClass.getConstructor(BeanDefinitionRegistry.class).newInstance(this.registry);
// Delegate the current ResourceLoader to it if possible
if (readerInstance instanceof AbstractBeanDefinitionReader) {
AbstractBeanDefinitionReader abdr = ((AbstractBeanDefinitionReader) readerInstance);
abdr.setResourceLoader(this.resourceLoader);
abdr.setEnvironment(this.environment);
}
readerInstanceCache.put(readerClass, readerInstance);
}
catch (Exception ex) {
throw new IllegalStateException("Could not instantiate BeanDefinitionReader class [" + readerClass.getName() + "]");
}
}
BeanDefinitionReader reader = readerInstanceCache.get(readerClass);
// TODO SPR-6310: qualify relative path locations as done in AbstractContextLoader.modifyLocations
reader.loadBeanDefinitions(resource);
}
}