|
|
|
@ -26,6 +26,7 @@ import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; |
|
|
|
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; |
|
|
|
import org.springframework.beans.factory.annotation.Autowire; |
|
|
|
import org.springframework.beans.factory.annotation.Autowire; |
|
|
|
import org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor; |
|
|
|
import org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor; |
|
|
|
@ -41,8 +42,6 @@ import org.springframework.core.annotation.AnnotationUtils; |
|
|
|
import org.springframework.core.io.Resource; |
|
|
|
import org.springframework.core.io.Resource; |
|
|
|
import org.springframework.core.type.AnnotationMetadata; |
|
|
|
import org.springframework.core.type.AnnotationMetadata; |
|
|
|
import org.springframework.core.type.MethodMetadata; |
|
|
|
import org.springframework.core.type.MethodMetadata; |
|
|
|
import org.springframework.util.ClassUtils; |
|
|
|
|
|
|
|
import org.springframework.util.ReflectionUtils; |
|
|
|
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -214,28 +213,24 @@ class ConfigurationClassBeanDefinitionReader { |
|
|
|
registry.registerBeanDefinition(beanName, beanDefToRegister); |
|
|
|
registry.registerBeanDefinition(beanName, beanDefToRegister); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void loadBeanDefinitionsFromImportedResources(Map<String, String> importedResources) { |
|
|
|
private void loadBeanDefinitionsFromImportedResources(Map<String, Class> importedResources) { |
|
|
|
|
|
|
|
Map<Class, BeanDefinitionReader> readerInstanceCache = new HashMap<Class, BeanDefinitionReader>(); |
|
|
|
HashMap<String, BeanDefinitionReader> readerInstanceCache = new HashMap<String, BeanDefinitionReader>(); |
|
|
|
for (Map.Entry<String, Class> entry : importedResources.entrySet()) { |
|
|
|
|
|
|
|
String resource = entry.getKey(); |
|
|
|
for (String resource : importedResources.keySet()) { |
|
|
|
Class readerClass = entry.getValue(); |
|
|
|
String readerClassName = importedResources.get(resource); |
|
|
|
if (!readerInstanceCache.containsKey(readerClass)) { |
|
|
|
|
|
|
|
|
|
|
|
if (!readerInstanceCache.containsKey(readerClassName)) { |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
BeanDefinitionReader readerInstance = (BeanDefinitionReader) |
|
|
|
Class<? extends BeanDefinitionReader> readerClass = |
|
|
|
readerClass.getConstructor(BeanDefinitionRegistry.class).newInstance(this.registry); |
|
|
|
(Class<? extends BeanDefinitionReader>) ClassUtils.forName(readerClassName, ClassUtils.getDefaultClassLoader()); |
|
|
|
readerInstanceCache.put(readerClass, readerInstance); |
|
|
|
BeanDefinitionReader readerInstance = readerClass.getConstructor(BeanDefinitionRegistry.class).newInstance(this.registry); |
|
|
|
} |
|
|
|
readerInstanceCache.put(readerClassName, readerInstance); |
|
|
|
catch (Exception ex) { |
|
|
|
} catch (Exception ex) { |
|
|
|
throw new IllegalStateException("Could not instantiate BeanDefinitionReader class [" + readerClass.getName() + "]"); |
|
|
|
ReflectionUtils.handleReflectionException(ex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
BeanDefinitionReader reader = readerInstanceCache.get(readerClass); |
|
|
|
BeanDefinitionReader reader = readerInstanceCache.get(readerClassName); |
|
|
|
|
|
|
|
// TODO SPR-6310: qualify relatively pathed locations as done in AbstractContextLoader.modifyLocations
|
|
|
|
// TODO SPR-6310: qualify relatively pathed locations as done in AbstractContextLoader.modifyLocations
|
|
|
|
reader.loadBeanDefinitions(importedResources.keySet().toArray(new String[]{})); |
|
|
|
reader.loadBeanDefinitions(resource); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|