diff --git a/spring-context/src/main/java/org/springframework/context/config/PropertyPlaceholderBeanDefinitionParser.java b/spring-context/src/main/java/org/springframework/context/config/PropertyPlaceholderBeanDefinitionParser.java
index bccffe48c8..f280159728 100644
--- a/spring-context/src/main/java/org/springframework/context/config/PropertyPlaceholderBeanDefinitionParser.java
+++ b/spring-context/src/main/java/org/springframework/context/config/PropertyPlaceholderBeanDefinitionParser.java
@@ -33,7 +33,7 @@ import org.springframework.util.StringUtils;
*/
class PropertyPlaceholderBeanDefinitionParser extends AbstractPropertyLoadingBeanDefinitionParser {
- private static final String SYSTEM_PROPERTIES_MODE_ATTRIB = "system-properties-mode";
+ private static final String SYSTEM_PROPERTIES_MODE_ATTRIBUTE = "system-properties-mode";
private static final String SYSTEM_PROPERTIES_MODE_DEFAULT = "ENVIRONMENT";
@@ -43,13 +43,13 @@ class PropertyPlaceholderBeanDefinitionParser extends AbstractPropertyLoadingBea
// As of Spring 3.1, the default value of system-properties-mode has changed from
// 'FALLBACK' to 'ENVIRONMENT'. This latter value indicates that resolution of
// placeholders against system properties is a function of the Environment and
- // its current set of PropertySources
- if (element.getAttribute(SYSTEM_PROPERTIES_MODE_ATTRIB).equals(SYSTEM_PROPERTIES_MODE_DEFAULT)) {
+ // its current set of PropertySources.
+ if (SYSTEM_PROPERTIES_MODE_DEFAULT.equals(element.getAttribute(SYSTEM_PROPERTIES_MODE_ATTRIBUTE))) {
return PropertySourcesPlaceholderConfigurer.class;
}
- // the user has explicitly specified a value for system-properties-mode. Revert
- // to PropertyPlaceholderConfigurer to ensure backward compatibility.
+ // The user has explicitly specified a value for system-properties-mode: revert to
+ // PropertyPlaceholderConfigurer to ensure backward compatibility with 3.0 and earlier.
return PropertyPlaceholderConfigurer.class;
}
@@ -60,12 +60,16 @@ class PropertyPlaceholderBeanDefinitionParser extends AbstractPropertyLoadingBea
builder.addPropertyValue("ignoreUnresolvablePlaceholders",
Boolean.valueOf(element.getAttribute("ignore-unresolvable")));
- String systemPropertiesModeName = element.getAttribute(SYSTEM_PROPERTIES_MODE_ATTRIB);
+ String systemPropertiesModeName = element.getAttribute(SYSTEM_PROPERTIES_MODE_ATTRIBUTE);
if (StringUtils.hasLength(systemPropertiesModeName) &&
!systemPropertiesModeName.equals(SYSTEM_PROPERTIES_MODE_DEFAULT)) {
builder.addPropertyValue("systemPropertiesModeName", "SYSTEM_PROPERTIES_MODE_" + systemPropertiesModeName);
}
+ if (element.hasAttribute("value-separator")) {
+ builder.addPropertyValue("valueSeparator", element.getAttribute("value-separator"));
+ }
+
if (element.hasAttribute("null-value")) {
builder.addPropertyValue("nullValue", element.getAttribute("null-value"));
}
diff --git a/spring-context/src/main/resources/org/springframework/context/config/spring-context-4.2.xsd b/spring-context/src/main/resources/org/springframework/context/config/spring-context-4.2.xsd
index 062d268032..a70b8097c1 100644
--- a/spring-context/src/main/resources/org/springframework/context/config/spring-context-4.2.xsd
+++ b/spring-context/src/main/resources/org/springframework/context/config/spring-context-4.2.xsd
@@ -144,6 +144,14 @@
+
+
+
+
+
beans = applicationContext
.getBeansOfType(PlaceholderConfigurerSupport.class);
assertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
- String s = (String) applicationContext.getBean("string");
- assertEquals("bar", s);
+ assertEquals("bar", applicationContext.getBean("string"));
assertEquals("null", applicationContext.getBean("nullString"));
}
@@ -69,11 +69,11 @@ public class ContextNamespaceHandlerTests {
Map beans = applicationContext
.getBeansOfType(PropertyPlaceholderConfigurer.class);
assertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
- String s = (String) applicationContext.getBean("string");
- assertEquals("spam", s);
+ assertEquals("spam", applicationContext.getBean("string"));
+ assertEquals("none", applicationContext.getBean("fallback"));
}
finally {
- if (value!=null) {
+ if (value != null) {
System.setProperty("foo", value);
}
}
@@ -89,8 +89,8 @@ public class ContextNamespaceHandlerTests {
Map beans = applicationContext
.getBeansOfType(PlaceholderConfigurerSupport.class);
assertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
- String s = (String) applicationContext.getBean("string");
- assertEquals("spam", s);
+ assertEquals("spam", applicationContext.getBean("string"));
+ assertEquals("none", applicationContext.getBean("fallback"));
}
@Test
@@ -100,12 +100,9 @@ public class ContextNamespaceHandlerTests {
Map beans = applicationContext
.getBeansOfType(PropertyPlaceholderConfigurer.class);
assertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
- String s = (String) applicationContext.getBean("foo");
- assertEquals("bar", s);
- s = (String) applicationContext.getBean("bar");
- assertEquals("foo", s);
- s = (String) applicationContext.getBean("spam");
- assertEquals("maps", s);
+ assertEquals("bar", applicationContext.getBean("foo"));
+ assertEquals("foo", applicationContext.getBean("bar"));
+ assertEquals("maps", applicationContext.getBean("spam"));
}
@Test
@@ -115,8 +112,7 @@ public class ContextNamespaceHandlerTests {
Map beans = applicationContext
.getBeansOfType(PlaceholderConfigurerSupport.class);
assertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
- String s = (String) applicationContext.getBean("string");
- assertEquals("${bar}", s);
+ assertEquals("${bar}", applicationContext.getBean("string"));
assertEquals("null", applicationContext.getBean("nullString"));
}
diff --git a/spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-simple.xml b/spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-simple.xml
index 9c9fe91923..42bd4335a2 100644
--- a/spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-simple.xml
+++ b/spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-simple.xml
@@ -11,4 +11,8 @@
+
+
+
+
diff --git a/spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-system.xml b/spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-system.xml
index d5268c52bc..18e2ad022e 100644
--- a/spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-system.xml
+++ b/spring-context/src/test/resources/org/springframework/context/config/contextNamespaceHandlerTests-system.xml
@@ -2,18 +2,22 @@
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">
bar
-
+
+
+
+
+