Issue Details (XML | Word | Printable)

Key: CONFIGURATION-338
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Oliver Heger
Reporter: David Donn
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Configuration

PropertiesConfiguration should allow variable interpolation for includes

Created: 08/Oct/08 07:33 AM   Updated: 22/Aug/09 07:36 PM
Return to search
Component/s: None
Affects Version/s: 1.5
Fix Version/s: 1.6

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works include-interpolation.patch 2008-10-09 06:37 AM David Donn 2 kB

Resolution Date: 10/Oct/08 07:38 PM


 Description  « Hide
It would be nice if Include files were subject to the same variable interpolation as regular properties.

e.g. it should be possible to do
include=${sys:myfilename}

I think it is simply a matter of changing the call in to loadIncludeFile() PropertiesConfiguration.propertyLoaded() from:

loadIncludeFile(files[i].trim());

to:

loadIncludeFile(interpolate(files[i].trim()));

I am happy to submit a patch.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Oliver Heger added a comment - 08/Oct/08 08:05 PM
Many thanks!

A patch would be appreciated. Any chance you could also provide a unit test?


David Donn added a comment - 09/Oct/08 06:37 AM
I have attached my patch. It includes a test. Please let me know if there are any problems and I will fix as this feature it quite important for me so I am keen to get it included.

David Donn made changes - 09/Oct/08 06:37 AM
Field Original Value New Value
Attachment include-interpolation.patch [ 12391796 ]
Repository Revision Date User Message
ASF #703248 Thu Oct 09 20:29:13 UTC 2008 oheger [CONFIGURATION-338] PropertiesConfiguration now performs interpolation when searching for include files; thanks to David Donn (david_donn at pacific dot net dot au) for the patch
Files Changed
MODIFY /commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java
MODIFY /commons/proper/configuration/trunk/conf/test.properties
MODIFY /commons/proper/configuration/trunk/xdocs/changes.xml
ADD /commons/proper/configuration/trunk/conf/include-interpol.properties
MODIFY /commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java

Oliver Heger added a comment - 09/Oct/08 08:31 PM
Patch applied in revision r703248. Many thanks!

(Leaving open until the patch is also applied to the configuration2 branch.)


Repository Revision Date User Message
ASF #703563 Fri Oct 10 19:35:24 UTC 2008 oheger [CONFIGURATION-338] PropertiesConfiguration now performs interpolation when searching for include files; thanks to David Donn (david_donn at pacific dot net dot au) for the patch.
Porting this patch to configuration2 branch.
Files Changed
ADD /commons/proper/configuration/branches/configuration2_experimental/src/test/resources/include-interpol.properties
MODIFY /commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
MODIFY /commons/proper/configuration/branches/configuration2_experimental/src/test/resources/test.properties
MODIFY /commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java
MODIFY /commons/proper/configuration/branches/configuration2_experimental/xdocs/changes.xml

Oliver Heger added a comment - 10/Oct/08 07:38 PM
The patch was also ported to the configuration2 branch.

Oliver Heger made changes - 10/Oct/08 07:38 PM
Resolution Fixed [ 1 ]
Fix Version/s 1.6 [ 12312450 ]
Assignee Oliver Heger [ oliver.heger@t-online.de ]
Status Open [ 1 ] Resolved [ 5 ]
Oliver Heger made changes - 22/Aug/09 07:36 PM
Status Resolved [ 5 ] Closed [ 6 ]