Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 68635 invoked from network); 30 Nov 2006 21:44:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Nov 2006 21:44:04 -0000 Received: (qmail 59166 invoked by uid 500); 30 Nov 2006 21:44:08 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 59116 invoked by uid 500); 30 Nov 2006 21:44:07 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 59105 invoked by uid 99); 30 Nov 2006 21:44:07 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Nov 2006 13:44:07 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of mdiggory@gmail.com designates 66.249.92.168 as permitted sender) Received: from [66.249.92.168] (HELO ug-out-1314.google.com) (66.249.92.168) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Nov 2006 13:43:56 -0800 Received: by ug-out-1314.google.com with SMTP id 32so1980829ugm for ; Thu, 30 Nov 2006 13:43:34 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=Xogksv2TxC0qXa/zYRvpURLhedWMzhqWEhO1Whz/qTDBBpRXQ6ddroFoI5yld9lGxI7xy6NYaiQOQ3wuZpBD5X+YcskGakNB9IBlmsCWPVHIhJFO6gSvDySj7EeizeFgEbMU7luzTFR+N0qYEXKFdh2CeYeDQk4AAOQ6htGOsDE= Received: by 10.78.138.6 with SMTP id l6mr4045497hud.1164923013228; Thu, 30 Nov 2006 13:43:33 -0800 (PST) Received: by 10.78.166.1 with HTTP; Thu, 30 Nov 2006 13:43:33 -0800 (PST) Message-ID: Date: Thu, 30 Nov 2006 16:43:33 -0500 From: "Mark Diggory" To: "Jakarta Commons Users List" Subject: Re: [configuration] Variable Interpolation doesn't happen in subset() and configurationAt() In-Reply-To: <456F4A85.60406@oliver-heger.de> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_64230_12257263.1164923013135" References: <456F4A85.60406@oliver-heger.de> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_64230_12257263.1164923013135 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanks, this is interesting news, I'll dig deeper into my configuration. And tray a few other tests. Is there a way to turn interpolation off/on? thanks, Mark On 11/30/06, Oliver Heger wrote: > > Mark Diggory wrote: > > I'm trying to use variable interpolation in version 1.3 I'm unsure of > the > > behavior with Sub-configurations. I'm wondering if interpolation should > > work > > in these as well (i.e. using the entire configuration to interpolate > > against. For instance if I have > > > > base.dir=/home/foo > > > > test.absolute.dir.x=${base.dir}/mypath > > test.absolute.dir.y=${base.dir}/mypath1 > > test.absolute.dir.z=${base.dir}/mypath2 > > > > If I call something like: > > > > Configuration config = configuration.configurationAt("test.absolute.dir > "); > > for (Iterator iter = config.getKeys(); iter.hasNext();) > > { > > String key = (String) iter.next(); > > System.out.println(key + "=" + config.getString(key)); > > } > > > > this prints out > > > > x=${base.dir}/mypath > > y=${base.dir}/mypath1 > > z=${base.dir}/mypath2 > > > > I was naively expecting > > > > x=/home/foo/mypath > > y=/home/foo/mypath1 > > z=/home/foo/mypath2 > > > > Thoughts? > > Mark > > > > Not sure what happens here. Based on your code fragment I added the > following test case to TestSubnodeConfiguration [1]: > > > public void testInterpolationFromConfigurationAt() > { > parent.addProperty("base.dir", "/home/foo"); > parent.addProperty("test.absolute.dir.dir1", "${base.dir > }/path1"); > parent.addProperty("test.absolute.dir.dir2", "${base.dir > }/path2"); > parent.addProperty("test.absolute.dir.dir3", "${base.dir > }/path3"); > > Configuration sub = parent.configurationAt("test.absolute.dir"); > for(int i = 1; i < 4; i++) > { > assertEquals("Wrong interpolation in parent", > "/home/foo/path" + i, parent.getString("test.absolute.dir.dir" + i)); > assertEquals("Wrong interpolation in subnode", > "/home/foo/path" + i, sub.getString("dir" + i)); > } > } > > and it works. SubnodeConfiguration overloads the interpolate() method > and calls interpolate() on its parent. So the whole key should be > evaluated. > > Don't know why you get different results. Do you use special expression > engines or something like that? > > Oliver > > [1] > > http://svn.apache.org/repos/asf/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestSubnodeConfiguration.java > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-user-help@jakarta.apache.org > > ------=_Part_64230_12257263.1164923013135--