Skip to content

Commit 3cb1cb5

Browse files
committed
ConfigurationClassParser considers EnvironmentAware on ImportBeanDefinitionRegistrars
Issue: SPR-11744
1 parent 79820e4 commit 3cb1cb5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.springframework.beans.factory.support.BeanDefinitionReader;
4343
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
4444
import org.springframework.beans.factory.support.BeanNameGenerator;
45+
import org.springframework.context.EnvironmentAware;
4546
import org.springframework.context.ResourceLoaderAware;
4647
import org.springframework.core.NestedIOException;
4748
import org.springframework.core.annotation.AnnotationAttributes;
@@ -411,11 +412,14 @@ private boolean checkAssignability(Class<?> clazz, Object candidate) throws IOEx
411412
}
412413

413414
/**
414-
* Invoke {@link ResourceLoaderAware}, {@link BeanClassLoaderAware} and
415-
* {@link BeanFactoryAware} contracts if implemented by the given {@code registrar}.
415+
* Invoke {@link EnvironmentAware}, {@link ResourceLoaderAware}, {@link BeanClassLoaderAware}
416+
* and {@link BeanFactoryAware} contracts if implemented by the given {@code registrar}.
416417
*/
417418
private void invokeAwareMethods(ImportBeanDefinitionRegistrar registrar) {
418419
if (registrar instanceof Aware) {
420+
if (registrar instanceof EnvironmentAware) {
421+
((EnvironmentAware) registrar).setEnvironment(this.environment);
422+
}
419423
if (registrar instanceof ResourceLoaderAware) {
420424
((ResourceLoaderAware) registrar).setResourceLoader(this.resourceLoader);
421425
}

0 commit comments

Comments
 (0)