Consistent Environment access in XML bean definition parsing code

Issue: SPR-12248
This commit is contained in:
Juergen Hoeller
2014-09-25 01:02:40 +02:00
parent b0e6091cad
commit 5ecdd8ca31
8 changed files with 53 additions and 62 deletions

View File

@@ -103,8 +103,7 @@ public class ClassPathBeanDefinitionScanner extends ClassPathScanningCandidateCo
* {@link org.springframework.stereotype.Component @Component},
* {@link org.springframework.stereotype.Repository @Repository},
* {@link org.springframework.stereotype.Service @Service}, and
* {@link org.springframework.stereotype.Controller @Controller} stereotype
* annotations.
* {@link org.springframework.stereotype.Controller @Controller} stereotype annotations
* @see #setResourceLoader
* @see #setEnvironment
*/
@@ -124,13 +123,12 @@ public class ClassPathBeanDefinitionScanner extends ClassPathScanningCandidateCo
* @param registry the {@code BeanFactory} to load bean definitions into, in the form
* of a {@code BeanDefinitionRegistry}
* @param useDefaultFilters whether to include the default filters for the
* @param environment the Spring {@link Environment} to use when evaluating bean
* definition profile metadata.
* {@link org.springframework.stereotype.Component @Component},
* {@link org.springframework.stereotype.Repository @Repository},
* {@link org.springframework.stereotype.Service @Service}, and
* {@link org.springframework.stereotype.Controller @Controller} stereotype
* annotations.
* {@link org.springframework.stereotype.Controller @Controller} stereotype annotations
* @param environment the Spring {@link Environment} to use when evaluating bean
* definition profile metadata
* @since 3.1
* @see #setResourceLoader
*/

View File

@@ -115,6 +115,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
if (useDefaultFilters) {
registerDefaultFilters();
}
Assert.notNull(environment, "Environment must not be null");
this.environment = environment;
}
@@ -161,10 +162,11 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
/**
* Set the Environment to use when resolving placeholders and evaluating
* {@link Conditional @Conditional}-annotated component classes.
* <p>The default is a {@link StandardEnvironment}
* <p>The default is a {@link StandardEnvironment}.
* @param environment the Environment to use
*/
public void setEnvironment(Environment environment) {
Assert.notNull(environment, "Environment must not be null");
this.environment = environment;
this.conditionEvaluator = null;
}