diff --git a/spring-context/src/main/java/org/springframework/context/support/ApplicationContextAwareProcessor.java b/spring-context/src/main/java/org/springframework/context/support/ApplicationContextAwareProcessor.java index c6d856f16de..1a5a6ecf69b 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ApplicationContextAwareProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/support/ApplicationContextAwareProcessor.java @@ -21,7 +21,6 @@ import java.security.AccessController; import java.security.PrivilegedAction; import org.springframework.beans.BeansException; -import org.springframework.beans.factory.Aware; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.EmbeddedValueResolver; import org.springframework.context.ApplicationContextAware; @@ -35,13 +34,15 @@ import org.springframework.lang.Nullable; import org.springframework.util.StringValueResolver; /** - * {@link org.springframework.beans.factory.config.BeanPostProcessor} - * implementation that passes the ApplicationContext to beans that + * {@link BeanPostProcessor} implementation that supplies the {@code ApplicationContext}, + * {@link org.springframework.core.env.Environment Environment}, or + * {@link StringValueResolver} for the {@code ApplicationContext} to beans that * implement the {@link EnvironmentAware}, {@link EmbeddedValueResolverAware}, * {@link ResourceLoaderAware}, {@link ApplicationEventPublisherAware}, - * {@link MessageSourceAware} and/or {@link ApplicationContextAware} interfaces. + * {@link MessageSourceAware}, and/or {@link ApplicationContextAware} interfaces. * - *
Implemented interfaces are satisfied in order of their mention above. + *
Implemented interfaces are satisfied in the order in which they are + * mentioned above. * *
Application contexts will automatically register this with their * underlying bean factory. Applications do not use this directly. @@ -103,25 +104,23 @@ class ApplicationContextAwareProcessor implements BeanPostProcessor { } private void invokeAwareInterfaces(Object bean) { - if (bean instanceof Aware) { - if (bean instanceof EnvironmentAware) { - ((EnvironmentAware) bean).setEnvironment(this.applicationContext.getEnvironment()); - } - if (bean instanceof EmbeddedValueResolverAware) { - ((EmbeddedValueResolverAware) bean).setEmbeddedValueResolver(this.embeddedValueResolver); - } - if (bean instanceof ResourceLoaderAware) { - ((ResourceLoaderAware) bean).setResourceLoader(this.applicationContext); - } - if (bean instanceof ApplicationEventPublisherAware) { - ((ApplicationEventPublisherAware) bean).setApplicationEventPublisher(this.applicationContext); - } - if (bean instanceof MessageSourceAware) { - ((MessageSourceAware) bean).setMessageSource(this.applicationContext); - } - if (bean instanceof ApplicationContextAware) { - ((ApplicationContextAware) bean).setApplicationContext(this.applicationContext); - } + if (bean instanceof EnvironmentAware) { + ((EnvironmentAware) bean).setEnvironment(this.applicationContext.getEnvironment()); + } + if (bean instanceof EmbeddedValueResolverAware) { + ((EmbeddedValueResolverAware) bean).setEmbeddedValueResolver(this.embeddedValueResolver); + } + if (bean instanceof ResourceLoaderAware) { + ((ResourceLoaderAware) bean).setResourceLoader(this.applicationContext); + } + if (bean instanceof ApplicationEventPublisherAware) { + ((ApplicationEventPublisherAware) bean).setApplicationEventPublisher(this.applicationContext); + } + if (bean instanceof MessageSourceAware) { + ((MessageSourceAware) bean).setMessageSource(this.applicationContext); + } + if (bean instanceof ApplicationContextAware) { + ((ApplicationContextAware) bean).setApplicationContext(this.applicationContext); } }