diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java index be90a686eba..e6f13861d44 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java +++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java @@ -248,14 +248,22 @@ class ConfigurationClassParser { // the candidate class is an ImportSelector -> delegate to it to determine imports try { ImportSelector selector = BeanUtils.instantiateClass(Class.forName(candidate), ImportSelector.class); - ImportSelectorContext context = new ImportSelectorContext(importingClassMetadata, this.registry); - processImport(configClass, selector.selectImports(context), false); + processImport(configClass, selector.selectImports(importingClassMetadata), false); + } catch (ClassNotFoundException ex) { + throw new IllegalStateException(ex); + } + } + else if (new AssignableTypeFilter(ImportBeanDefinitionRegistrar.class).match(reader, metadataReaderFactory)) { + // the candidate class is an ImportBeanDefinitionRegistrar -> delegate to it to register additional bean definitions + try { + ImportBeanDefinitionRegistrar registrar = BeanUtils.instantiateClass(Class.forName(candidate), ImportBeanDefinitionRegistrar.class); + registrar.registerBeanDefinitions(importingClassMetadata, registry); } catch (ClassNotFoundException ex) { throw new IllegalStateException(ex); } } else { - // the candidate class not an ImportSelector -> process it as a @Configuration class + // the candidate class not an ImportSelector or ImportBeanDefinitionRegistrar -> process it as a @Configuration class this.importStack.registerImport(importingClassMetadata.getClassName(), candidate); processConfigurationClass(new ConfigurationClass(reader, null)); } @@ -323,16 +331,16 @@ class ConfigurationClassParser { /** * Given a stack containing (in order) - *