Issue Details (XML | Word | Printable)

Key: SPR-1332
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Juergen Hoeller
Reporter: Cameron Taggart
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Spring Framework

${...} placeholders support for import

Created: 28/Sep/05 01:10 PM   Updated: 04/Nov/05 10:08 AM
Component/s: SpringCORE
Affects Version/s: None
Fix Version/s: 1.2.6

Time Tracking:
Not Specified


 Description  « Hide
Please add ${...} placeholders support for <import resource="${...}"/>. That would enable us to do something like:
<import resource="file:${catalina.base}/conf/app-conf/messaging.xml"/>

I started a forum topic about this yesterday, but this is probably a better spot for the feature request.
http://forum.springframework.org/viewtopic.php?t=9193

I imagine this request is similar to the changes you made for Log4J in Spring 1.2.5, Log4jConfigurer resolves ${...} placeholders in Log4J config locations as system properties.

My goal is to allow configuration of webapps from outside the war. Today, we can do that using properties files, but I don't know of any way to do that xml files. Any suggestions? Here are some snippets to explain:

<import resource="file:${catalina.base}/conf/app-conf/messaging.xml"/>

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>WEB-INF/messaging.default.properties</value>
<value>file:${catalina.base}/conf/app-conf/messaging.properties</value>
</list>
</property>
</bean>

Thanks,
Cameron



 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Juergen Hoeller added a comment - 01/Oct/05 02:06 PM
Thanks for the suggestion! I've added such support for system property placeholders for import location, similar to the placeholder support for Log4J config locations.

Juergen


Joe Shomphe added a comment - 06/Oct/05 01:41 PM
This only seems to work with enviornment variables, not with variables pulled from a property file:

IE, if I run my test with -Dprop.name=FOO

<import resource="${property.name}Context.xml"/> will load

if I do the following without the -Dprop.name flag:

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" autowire="no">
<property name="locations">
<list>
<value>file:${user.home}/test.properties</value>
</list>
</property>
<property name="ignoreResourceNotFound">
<value>true</value>
</property>
</bean>

and have a prop.name entry in test.properties

this no longer works


Cameron Taggart added a comment - 06/Oct/05 03:10 PM
Joe, that is correct. I've requested and Juergen has added support for system properties, not those from properties files.

Cameron Taggart added a comment - 04/Nov/05 10:08 AM
Spring version 1.2.6 still isn't out yet. I'm really looking forward to this bug fix.

Thanks,
Cameron