RESOLVED - issue SPR-4661: Improve context-property-placeholder configurability
Added new features to property override and placeholders (order, locations, system-properties-mode, ignore-*)
This commit is contained in:
@@ -28,6 +28,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Arjen Poutsma
|
||||
* @author Dave Syer
|
||||
* @since 2.5.2
|
||||
*/
|
||||
abstract class AbstractPropertyLoadingBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
|
||||
@@ -44,10 +45,28 @@ abstract class AbstractPropertyLoadingBeanDefinitionParser extends AbstractSingl
|
||||
String[] locations = StringUtils.commaDelimitedListToStringArray(location);
|
||||
builder.addPropertyValue("locations", locations);
|
||||
}
|
||||
|
||||
String propertiesRef = element.getAttribute("properties-ref");
|
||||
if (StringUtils.hasLength(propertiesRef)) {
|
||||
builder.addPropertyReference("properties", propertiesRef);
|
||||
}
|
||||
|
||||
String fileEncoding = element.getAttribute("file-encoding");
|
||||
if (StringUtils.hasLength(fileEncoding)) {
|
||||
builder.addPropertyReference("fileEncoding", fileEncoding);
|
||||
}
|
||||
|
||||
String order = element.getAttribute("order");
|
||||
if (StringUtils.hasLength(order)) {
|
||||
builder.addPropertyValue("order", Integer.valueOf(order));
|
||||
}
|
||||
|
||||
builder.addPropertyValue("ignoreResourceNotFound",
|
||||
Boolean.valueOf(element.getAttribute("ignore-resource-not-found")));
|
||||
|
||||
builder.addPropertyValue("localOverride",
|
||||
Boolean.valueOf(element.getAttribute("local-override")));
|
||||
|
||||
builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,13 @@ package org.springframework.context.config;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.config.PropertyOverrideConfigurer;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
|
||||
/**
|
||||
* Parser for the <context:property-override/> element.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Dave Syer
|
||||
* @since 2.5.2
|
||||
*/
|
||||
class PropertyOverrideBeanDefinitionParser extends AbstractPropertyLoadingBeanDefinitionParser {
|
||||
@@ -32,5 +34,14 @@ class PropertyOverrideBeanDefinitionParser extends AbstractPropertyLoadingBeanDe
|
||||
protected Class getBeanClass(Element element) {
|
||||
return PropertyOverrideConfigurer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, BeanDefinitionBuilder builder) {
|
||||
|
||||
super.doParse(element, builder);
|
||||
builder.addPropertyValue("ignoreInvalidKeys",
|
||||
Boolean.valueOf(element.getAttribute("ignore-unresolvable")));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,11 +19,14 @@ package org.springframework.context.config;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Parser for the <context:property-placeholder/> element.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Dave Syer
|
||||
* @since 2.5
|
||||
*/
|
||||
class PropertyPlaceholderBeanDefinitionParser extends AbstractPropertyLoadingBeanDefinitionParser {
|
||||
@@ -32,5 +35,20 @@ class PropertyPlaceholderBeanDefinitionParser extends AbstractPropertyLoadingBea
|
||||
protected Class getBeanClass(Element element) {
|
||||
return PropertyPlaceholderConfigurer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, BeanDefinitionBuilder builder) {
|
||||
|
||||
super.doParse(element, builder);
|
||||
|
||||
builder.addPropertyValue("ignoreUnresolvablePlaceholders",
|
||||
Boolean.valueOf(element.getAttribute("ignore-unresolvable")));
|
||||
|
||||
String systemPropertiesModeName = element.getAttribute("system-properties-mode");
|
||||
if (StringUtils.hasLength(systemPropertiesModeName)) {
|
||||
builder.addPropertyValue("systemPropertiesModeName", "SYSTEM_PROPERTIES_MODE_"+systemPropertiesModeName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user