commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
Subject Re: [Commons Config]URL resolving
Date Sat, 10 Jun 2006 15:47:52 GMT
Okay, I think I got it now. You would like to have a predefined variable 
like ${config_url} for instance, which is automatically replaced by the 
URL of the current configuration file, right?

Well, ATM this is not supported, but I think, it is a good idea. Maybe 
it would make sense to have more of these predefined variables providing 
meta information about the current set of properties (e.g. configuration 
class, time when the file was loaded, etc.)?

Would you please so kind to open a new enhancement request in JIRA, so 
that the idea won't get lost? (see [1])

I plan to change/enhance the interpolation features anyway; this would 
be an opportunity to implement this new feature.

Thanks.
Oliver

[1] http://jakarta.apache.org/commons/configuration/issue-tracking.html

Michiel Kalkman wrote:
> hm,
> let me try again...
> 
> This was the original situation:
> root/A/config.xml
> root/A/specificConfigForB.xml
> root/A/log4jConfigForB.xml
> 
> I want to retrieve the URL of the log4jConfigForB.xml which is specified
> relative to specificConfigForB.xml.
> 
> I know the URL for root/A/config.xml.
> This file imports specificConfigForB.xml which specifies the name of the
> log4j config file.
> The URL to the log4j config file was constructed through new URL(
> 'root/A/config.xml', 'log4jConfigForB.xml'). The result is
> root/A/log4jConfigForB.xml
> 
> However, when specificConfigForB.xml and log4jConfigForB.xml move to root/B
> (or whereever) the result will still be root/A/log4jConfigForB.xml. 
> Which is
> clearly wrong.
> 
> I prefer not having to specify an absolute URL to log4jConfigForB.xml.
> Adding the content of log4jConfigForB.xml to specificConfigForB.xml is also
> no option.
> 
> My original idea was therefore that there might be a construct like a
> special variable that is set by the parser when a file is being parsed. 
> This
> variable would then be filled with the URL to that particular file.
> 
> My question: is there such a construct ? Or can I determine somehow in 
> which
> file a configuration parameter is set ? Or is there another option ?
> 
> I hope this clearer ...
> 
> Thanks,
> Michiel
> 
> On 6/8/06, Oliver Heger <oliver.heger@oliver-heger.de> wrote:
>>
>> Michiel Kalkman wrote:
>> > Hi,
>> >
>> > I'd like to be able to do the following. I have the following directory
>> > structure:
>> >
>> > root/A/config.xml
>> > root/B/specificConfigForB.xml
>> > root/B/log4jConfigForB.xml
>> >
>> > root/A/config.xml looks like:
>> > <configuration>
>> >  <xml fileName="../B/specificConfigForB.xml"/>
>> > </configuration>
>> >
>> > root/B/specificConfigForB.xml refers to the location of log4j like:
>> > <configuration>
>> >
>> <log4j-url>${some-predefined-variable-resolved-at-runtime}/log4j.xml</log4j-url>

>>
>> >
>> > </configuration>
>> >
>> > The idea is that when I do something like config.getString( 
>> "log4j-url")
>> I
>> > want the location of the log4j.xml, like
>> > root/b/log4j.xml (and not root/a/log4j.xml).
>> >
>> > Is something like this possible ?
>> >
>> > If so, how ?
>> >
>> > Thanks and regards,
>> > Michiel
>> >
>>
>> Hello,
>>
>> I am not sure if I understand your question correctly. Do you want to
>> know if there is a mechanism of using variables in a configuration file
>> that can be replaced by current values? Then the answer is yes; have a
>> look at
>>
>> http://jakarta.apache.org/commons/configuration/howto_properties.html#Variable%20Interpolation

>>
>>
>> Oliver
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message