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:
David Syer
2009-10-27 13:38:29 +00:00
parent c63cdb2444
commit a29253f2ca
13 changed files with 338 additions and 93 deletions

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<context:property-placeholder
location="classpath:/org/springframework/context/config/test-*.properties, classpath:/org/springframework/context/config/empty-*.properties, classpath:/org/springframework/context/config/missing-*.properties" />
<bean id="foo" class="java.lang.String">
<constructor-arg value="${foo}" />
</bean>
<bean id="bar" class="java.lang.String">
<constructor-arg value="${bar}" />
</bean>
<bean id="spam" class="java.lang.String">
<constructor-arg value="${spam}" />
</bean>
</beans>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<util:properties id="overrideProps">
<prop key="date.minutes">42</prop>
</util:properties>
<context:property-override properties-ref="overrideProps" order="1" />
<bean id="date" class="java.util.Date">
<property name="minutes" value="10"/>
</bean>
<context:property-override location="not/here" ignore-resource-not-found="true" order="2"/>
</beans>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<util:properties id="placeholderProps">
<prop key="foo">bar</prop>
</util:properties>
<context:property-placeholder properties-ref="placeholderProps" ignore-unresolvable="true"/>
<bean id="string" class="java.lang.String">
<constructor-arg value="${bar}"/>
</bean>
</beans>

View File

@@ -2,26 +2,23 @@
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<util:properties id="placeholderProps">
<prop key="foo">bar</prop>
</util:properties>
<context:property-placeholder properties-ref="placeholderProps"/>
<util:properties id="emptyProps"/>
<context:property-placeholder properties-ref="placeholderProps" order="2"/>
<context:property-placeholder properties-ref="emptyProps" order="1" ignore-unresolvable="true"/>
<context:property-placeholder location="not/here" ignore-resource-not-found="true" order="2"/>
<bean id="string" class="java.lang.String">
<constructor-arg value="${foo}"/>
</bean>
<util:properties id="overrideProps">
<prop key="date.minutes">42</prop>
</util:properties>
<context:property-override properties-ref="overrideProps"/>
<bean id="date" class="java.util.Date">
<property name="minutes" value="10"/>
</bean>
</beans>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<util:properties id="placeholderProps">
<prop key="foo">bar</prop>
</util:properties>
<context:property-placeholder properties-ref="placeholderProps" system-properties-mode="OVERRIDE"/>
<bean id="string" class="java.lang.String">
<constructor-arg value="${foo}"/>
</bean>
</beans>