commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rishikesh.Mall...@atradius.com
Subject RE: Commons configuration: Filename and namespace.
Date Tue, 28 Mar 2006 13:13:54 GMT
>>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


Mime
View raw message