On 7/12/14, 9:52 AM, Oliver Heger wrote: > Hi Ronald, > > I have not used ExprLookup myself, so I am not sure whether I am a big > help here. > > Your declaration of the lookup seems to be correct, otherwise an > exception would be thrown by DefaultConfigurationBuilder. > > A difference between your code and the example in the user's guide is > that in the latter the expression lookup is directly used in the file > read by DefaultConfigurationBuilder and not in one of the included > configuration files. For version 2.0 (which is work in progress) this > should be supported, but I am not sure whether this also works in 1.x. > > I would recommend to start with a simple example first. Test whether you > can access the lookup directly in this xml file, e.g. by setting the > file name of a configuration source as demonstrated in the example. By > this you can find out the results of variable substitutions and compare > them with your expectations. Only if this works as expected, try again > to use the lookup in an included configuration source.
I also have no experience using this feature, but IIUC you are trying to use "expr" as a prefix. According to the doc, that is not among the supported prefixes. Phil > > HTH > Oliver > > Am 11.07.2014 17:27, schrieb DiFrango, Ronald (CONT): >> Here's the full XML file: >> >> <?xml version="1.0" encoding="ISO-8859-1" ?> >> >> <configuration> >> <header> >> <result /> >> <lookups> >> <lookup config-prefix="expr" >> >> config-class="org.apache.commons.configuration.interpol.ExprLookup"> >> <variables> >> <variable name="net" >> value="Class:java.net.InetAddress" /> >> </variables> >> </lookup> >> </lookups> >> </header> >> >> <system /> >> >> <properties fileName=" example.properties" listDelimiter="|"> >> <reloadingStrategy refreshDelay="10000" >> >> config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy" >> /> >> </properties> >> >> </configuration> >> >> And the referenced properties file: >> >> mobile.rest.host=${expr:$[net.localHost.hostName]} >> >> >> Ron DiFrango >> >> >> >> -----Original Message----- >> From: Martin Gainty [mailto:mgai...@hotmail.com] >> Sent: Friday, July 11, 2014 11:25 AM >> To: Commons Users List >> Subject: RE: Commons Config: Variable Interpolation >> >> >> >>> From: ronald.difra...@capitalone.com >>> To: user@commons.apache.org >>> Date: Fri, 11 Jul 2014 11:02:45 -0400 >>> Subject: RE: Commons Config: Variable Interpolation >>> >>> Just to complete it, the code looks like: >>> >>> DefaultConfigurationBuilder factory = new >>> DefaultConfigurationBuilder("example.xml"); >>> Configuration config = factory.getConfiguration(); >> MG>no clue which properties are defined in example.xml so lets add a new >> MG>property called mobile.rest.host here >> MG>config.addProperty("mobile.rest.host", "maps.google.com"); >> >>> System.out.println("Host Name = " + >>> config.getString("mobile.rest.host")); >> MG>? >>> Ron DiFrango >>> >>> >>> -----Original Message----- >>> From: DiFrango, Ronald (CONT) [mailto:ronald.difra...@capitalone.com] >>> Sent: Friday, July 11, 2014 10:49 AM >>> To: user@commons.apache.org >>> Subject: Commons Config: Variable Interpolation >>> >>> I'm attempting to perform Variable Interpolation as outlined here: >>> >>> http://commons.apache.org/proper/commons-configuration/userguide/howto >>> _basicfeatures.html#Variable_Interpolation >>> >>> I'm using an XML file as the starter so I added the following blurb to the >>> beginning of the file: >>> >>> <header> >>> <result /> >>> <lookups> >>> <lookup config-prefix="expr" >>> >>> config-class="org.apache.commons.configuration.interpol.ExprLookup"> >>> <variables> >>> <variable name="net" >>> value="Class:java.net.InetAddress" /> >>> </variables> >>> </lookup> >>> </lookups> >>> </header> >> MG> >> <override> >> <xml mobileRestHost="String.lowercase(net.localHost.hostName)"></xml> >> </override> >> MG>? >> >>> And then in my properties file that is loaded I did: >>> >>> mobile.rest.host=${expr:$[net.localHost.hostName]} >>> >>> But it did not work any thoughts on what I'm doing wrong? >>> >>> Thanks, >>> >>> Ron >>> >>> >>> ________________________________________________________ >>> >>> The information contained in this e-mail is confidential and/or proprietary >>> to Capital One and/or its affiliates. The information transmitted herewith >>> is intended only for use by the individual or entity to which it is >>> addressed. If the reader of this message is not the intended recipient, >>> you are hereby notified that any review, retransmission, dissemination, >>> distribution, copying or other use of, or taking of any action in reliance >>> upon this information is strictly prohibited. If you have received this >>> communication in error, please contact the sender and delete the material >>> from your computer. >>> ________________________________________________________ >>> >>> The information contained in this e-mail is confidential and/or proprietary >>> to Capital One and/or its affiliates. The information transmitted herewith >>> is intended only for use by the individual or entity to which it is >>> addressed. If the reader of this message is not the intended recipient, >>> you are hereby notified that any review, retransmission, dissemination, >>> distribution, copying or other use of, or taking of any action in reliance >>> upon this information is strictly prohibited. If you have received this >>> communication in error, please contact the sender and delete the material >>> from your computer. >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org >>> For additional commands, e-mail: user-h...@commons.apache.org >>> >> >> ________________________________________________________ >> >> The information contained in this e-mail is confidential and/or proprietary >> to Capital One and/or its affiliates. The information transmitted herewith >> is intended only for use by the individual or entity to which it is >> addressed. If the reader of this message is not the intended recipient, you >> are hereby notified that any review, retransmission, dissemination, >> distribution, copying or other use of, or taking of any action in reliance >> upon this information is strictly prohibited. If you have received this >> communication in error, please contact the sender and delete the material >> from your computer. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org >> For additional commands, e-mail: user-h...@commons.apache.org >> > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@commons.apache.org > For additional commands, e-mail: user-h...@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org