|
21 | 21 | import java.security.PrivilegedAction;
|
22 | 22 |
|
23 | 23 | import org.springframework.beans.BeansException;
|
24 |
| -import org.springframework.beans.factory.Aware; |
25 | 24 | import org.springframework.beans.factory.config.BeanPostProcessor;
|
26 | 25 | import org.springframework.beans.factory.config.EmbeddedValueResolver;
|
27 | 26 | import org.springframework.context.ApplicationContextAware;
|
|
35 | 34 | import org.springframework.util.StringValueResolver;
|
36 | 35 |
|
37 | 36 | /**
|
38 |
| - * {@link org.springframework.beans.factory.config.BeanPostProcessor} |
39 |
| - * implementation that passes the ApplicationContext to beans that |
| 37 | + * {@link BeanPostProcessor} implementation that supplies the {@code ApplicationContext}, |
| 38 | + * {@link org.springframework.core.env.Environment Environment}, or |
| 39 | + * {@link StringValueResolver} for the {@code ApplicationContext} to beans that |
40 | 40 | * implement the {@link EnvironmentAware}, {@link EmbeddedValueResolverAware},
|
41 | 41 | * {@link ResourceLoaderAware}, {@link ApplicationEventPublisherAware},
|
42 |
| - * {@link MessageSourceAware} and/or {@link ApplicationContextAware} interfaces. |
| 42 | + * {@link MessageSourceAware}, and/or {@link ApplicationContextAware} interfaces. |
43 | 43 | *
|
44 |
| - * <p>Implemented interfaces are satisfied in order of their mention above. |
| 44 | + * <p>Implemented interfaces are satisfied in the order in which they are |
| 45 | + * mentioned above. |
45 | 46 | *
|
46 | 47 | * <p>Application contexts will automatically register this with their
|
47 | 48 | * underlying bean factory. Applications do not use this directly.
|
@@ -103,25 +104,23 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) thro
|
103 | 104 | }
|
104 | 105 |
|
105 | 106 | private void invokeAwareInterfaces(Object bean) {
|
106 |
| - if (bean instanceof Aware) { |
107 |
| - if (bean instanceof EnvironmentAware) { |
108 |
| - ((EnvironmentAware) bean).setEnvironment(this.applicationContext.getEnvironment()); |
109 |
| - } |
110 |
| - if (bean instanceof EmbeddedValueResolverAware) { |
111 |
| - ((EmbeddedValueResolverAware) bean).setEmbeddedValueResolver(this.embeddedValueResolver); |
112 |
| - } |
113 |
| - if (bean instanceof ResourceLoaderAware) { |
114 |
| - ((ResourceLoaderAware) bean).setResourceLoader(this.applicationContext); |
115 |
| - } |
116 |
| - if (bean instanceof ApplicationEventPublisherAware) { |
117 |
| - ((ApplicationEventPublisherAware) bean).setApplicationEventPublisher(this.applicationContext); |
118 |
| - } |
119 |
| - if (bean instanceof MessageSourceAware) { |
120 |
| - ((MessageSourceAware) bean).setMessageSource(this.applicationContext); |
121 |
| - } |
122 |
| - if (bean instanceof ApplicationContextAware) { |
123 |
| - ((ApplicationContextAware) bean).setApplicationContext(this.applicationContext); |
124 |
| - } |
| 107 | + if (bean instanceof EnvironmentAware) { |
| 108 | + ((EnvironmentAware) bean).setEnvironment(this.applicationContext.getEnvironment()); |
| 109 | + } |
| 110 | + if (bean instanceof EmbeddedValueResolverAware) { |
| 111 | + ((EmbeddedValueResolverAware) bean).setEmbeddedValueResolver(this.embeddedValueResolver); |
| 112 | + } |
| 113 | + if (bean instanceof ResourceLoaderAware) { |
| 114 | + ((ResourceLoaderAware) bean).setResourceLoader(this.applicationContext); |
| 115 | + } |
| 116 | + if (bean instanceof ApplicationEventPublisherAware) { |
| 117 | + ((ApplicationEventPublisherAware) bean).setApplicationEventPublisher(this.applicationContext); |
| 118 | + } |
| 119 | + if (bean instanceof MessageSourceAware) { |
| 120 | + ((MessageSourceAware) bean).setMessageSource(this.applicationContext); |
| 121 | + } |
| 122 | + if (bean instanceof ApplicationContextAware) { |
| 123 | + ((ApplicationContextAware) bean).setApplicationContext(this.applicationContext); |
125 | 124 | }
|
126 | 125 | }
|
127 | 126 |
|
|
0 commit comments