parent
52d050d21a
commit
fc361844ec
|
@ -51,8 +51,8 @@ import org.springframework.util.Assert;
|
||||||
* <p>Enable debug- or trace-level logging for this class (or package) for messages
|
* <p>Enable debug- or trace-level logging for this class (or package) for messages
|
||||||
* explaining when these 'property name resolutions' occur.
|
* explaining when these 'property name resolutions' occur.
|
||||||
*
|
*
|
||||||
* <p>This property source is included by default in {@link StandardEnvironment} and all
|
* <p>This property source is included by default in {@link StandardEnvironment}
|
||||||
* its subclasses.
|
* and all its subclasses.
|
||||||
*
|
*
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
|
@ -76,7 +76,7 @@ public class SystemEnvironmentPropertySource extends MapPropertySource {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean containsProperty(String name) {
|
public boolean containsProperty(String name) {
|
||||||
return getProperty(name) != null;
|
return (getProperty(name) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,9 +89,8 @@ public class SystemEnvironmentPropertySource extends MapPropertySource {
|
||||||
Assert.notNull(name, "property name must not be null");
|
Assert.notNull(name, "property name must not be null");
|
||||||
String actualName = resolvePropertyName(name);
|
String actualName = resolvePropertyName(name);
|
||||||
if (logger.isDebugEnabled() && !name.equals(actualName)) {
|
if (logger.isDebugEnabled() && !name.equals(actualName)) {
|
||||||
logger.debug(String.format(
|
logger.debug(String.format("PropertySource [%s] does not contain '%s', but found equivalent '%s'",
|
||||||
"PropertySource [%s] does not contain '%s', but found equivalent '%s'",
|
getName(), name, actualName));
|
||||||
this.getName(), name, actualName));
|
|
||||||
}
|
}
|
||||||
return super.getProperty(actualName);
|
return super.getProperty(actualName);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +114,8 @@ public class SystemEnvironmentPropertySource extends MapPropertySource {
|
||||||
if (!name.equals(ucName)) {
|
if (!name.equals(ucName)) {
|
||||||
if (super.containsProperty(ucName)) {
|
if (super.containsProperty(ucName)) {
|
||||||
return ucName;
|
return ucName;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
String usUcName = ucName.replace('.', '_');
|
String usUcName = ucName.replace('.', '_');
|
||||||
if (!ucName.equals(usUcName) && super.containsProperty(usUcName)) {
|
if (!ucName.equals(usUcName) && super.containsProperty(usUcName)) {
|
||||||
return usUcName;
|
return usUcName;
|
||||||
|
|
|
@ -186,18 +186,17 @@ public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWe
|
||||||
@Override
|
@Override
|
||||||
protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) {
|
protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) {
|
||||||
AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(beanFactory);
|
AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(beanFactory);
|
||||||
reader.setEnvironment(this.getEnvironment());
|
reader.setEnvironment(getEnvironment());
|
||||||
|
|
||||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(beanFactory);
|
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(beanFactory);
|
||||||
scanner.setEnvironment(this.getEnvironment());
|
scanner.setEnvironment(getEnvironment());
|
||||||
|
|
||||||
BeanNameGenerator beanNameGenerator = getBeanNameGenerator();
|
BeanNameGenerator beanNameGenerator = getBeanNameGenerator();
|
||||||
ScopeMetadataResolver scopeMetadataResolver = getScopeMetadataResolver();
|
ScopeMetadataResolver scopeMetadataResolver = getScopeMetadataResolver();
|
||||||
if (beanNameGenerator != null) {
|
if (beanNameGenerator != null) {
|
||||||
reader.setBeanNameGenerator(beanNameGenerator);
|
reader.setBeanNameGenerator(beanNameGenerator);
|
||||||
scanner.setBeanNameGenerator(beanNameGenerator);
|
scanner.setBeanNameGenerator(beanNameGenerator);
|
||||||
beanFactory.registerSingleton(
|
beanFactory.registerSingleton(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR, beanNameGenerator);
|
||||||
AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR, beanNameGenerator);
|
|
||||||
}
|
}
|
||||||
if (scopeMetadataResolver != null) {
|
if (scopeMetadataResolver != null) {
|
||||||
reader.setScopeMetadataResolver(scopeMetadataResolver);
|
reader.setScopeMetadataResolver(scopeMetadataResolver);
|
||||||
|
|
|
@ -67,10 +67,10 @@ public class StandardServletEnvironment extends StandardEnvironment implements C
|
||||||
* {@value #JNDI_PROPERTY_SOURCE_NAME}.
|
* {@value #JNDI_PROPERTY_SOURCE_NAME}.
|
||||||
* <p>Properties in any of the above will take precedence over system properties and
|
* <p>Properties in any of the above will take precedence over system properties and
|
||||||
* environment variables contributed by the {@link StandardEnvironment} superclass.
|
* environment variables contributed by the {@link StandardEnvironment} superclass.
|
||||||
* <p>The {@code Servlet}-related property sources are added as {@link
|
* <p>The {@code Servlet}-related property sources are added as
|
||||||
* StubPropertySource stubs} at this stage, and will be {@linkplain
|
* {@link StubPropertySource stubs} at this stage, and will be
|
||||||
* #initPropertySources(ServletContext, ServletConfig) fully initialized} once the actual
|
* {@linkplain #initPropertySources(ServletContext, ServletConfig) fully initialized}
|
||||||
* {@link ServletContext} object becomes available.
|
* once the actual {@link ServletContext} object becomes available.
|
||||||
* @see StandardEnvironment#customizePropertySources
|
* @see StandardEnvironment#customizePropertySources
|
||||||
* @see org.springframework.core.env.AbstractEnvironment#customizePropertySources
|
* @see org.springframework.core.env.AbstractEnvironment#customizePropertySources
|
||||||
* @see ServletConfigPropertySource
|
* @see ServletConfigPropertySource
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2013 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -84,7 +84,7 @@ public class XmlWebApplicationContext extends AbstractRefreshableWebApplicationC
|
||||||
|
|
||||||
// Configure the bean definition reader with this context's
|
// Configure the bean definition reader with this context's
|
||||||
// resource loading environment.
|
// resource loading environment.
|
||||||
beanDefinitionReader.setEnvironment(this.getEnvironment());
|
beanDefinitionReader.setEnvironment(getEnvironment());
|
||||||
beanDefinitionReader.setResourceLoader(this);
|
beanDefinitionReader.setResourceLoader(this);
|
||||||
beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));
|
beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue