[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-user
Subject: RE: Commons configuration: Filename and namespace.
From: Rishikesh.Mallesh () atradius ! com
Date: 2006-03-28 13:13:54
Message-ID: C9E9D95C208A9144940B23B6F8B46A8C09C821BE () tmgbcdf1000 ! ncm ! com
[Download RAW message or body]
> > As a future enhancement it is planed to support names for configurations.
That's good news. Thanks for the help
-----Original Message-----
From: Oliver Heger [mailto:hegero@med.uni-marburg.de]
Sent: 28 March 2006 13:15
To: Jakarta Commons Users List
Subject: Re: Commons configuration: Filename and namespace.
Rishikesh.Mallesh@atradius.com wrote:
> Hi All,
>
>
>
> Question on commons configuration. I have asked this before as part of
> another thread...but afraid the question will get lost... so do excuse.
>
>
>
> One thing I wanted to add to my wish list for commons config is to have
the
> concept of using a file name as a namespace.
>
>
>
> For instance if I were to use ConfigurationFactory and I wanted to
retrieve
> all the configuration information from a particular configuration file
> (.xml, .properties etc), there is nothing directly supported (pls correct
me
> if I am wrong).
>
>
>
> I am currently loading individual files to get information from a specific
> file... not very elegant. What I would like is to have filenames being
> stored as a namespace (of sorts), it would allow us to -
>
>
>
> -----------------
>
> Configuration config = configFactory.getConfiguration();
>
> Configuration fileXConfig = config.getConfiguration(fileXName); // loads
the
> config info stored in file X only.
>
> -----------------
>
>
>
> Does this go against the philosophy of the ConfigurationFactory?? I have
> tried to reason it out and I don't think it does...
>
>
>
> Any ideas or thoughts?
>
>
>
> Thanks folks!
>
>
>
> Rishi
>
The Configuration object returned by ConfigurationFactory can be casted
to a CompositeConfiguration. This class allows you to access the
contained configurations based on a numeric index.
You could do something like that:
CompositeConfiguration cc = (CompositeConfiguration)
factory.getConfiguration();
Configuration configXML = cc.getConfiguration(0);
The configurations are in the order as they were declared in the
configuration definition file for the factory.
As a future enhancement it is planed to support names for
configurations. So you could write something like the following in the
configuration definition file:
<configuration>
<properties id="myMprops" fileName="..."/>
<xml id="myXml" fileName="..."/>
</configuration>
and then ask the CompositeConfiguration for a contained configuration by
name:
Configuration myProps = cc.getConfiguration("myProps");
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
------------------------------------------------------------------------------------------------------------
This message is intended for the addressee or its representative only.
Any form of unauthorized use, publication, reproduction, copying or
disclosure of the content of this e-mail is not permitted. If you are
not the intended recipient of this e-mail message and its contents,
please notify the sender immediately and delete this message and
all its attachments subsequently.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic