You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Wabner, Thomas (EXT)" <th...@siemens.com> on 2007/09/04 18:17:12 UTC

RE: [commons-configuration] - overloading a properties configuration - solved

Hi again,

I have solved this problem for myself.

After reading the complete documentation I have found the ConfigurationUtils#copy() method. This method does what I want ;-)

- waffel

Mit freundlichem Gruß / Best regards


Thomas Wabner

Siemens AG
Automation and Drives, A&D CoC Sales Configuration

SPICE - Service & Support
 
Tel.    : +49 (341) 4470-657
mailto:lpz.ipcbasis.aud@siemens.com
https://workspace.automation.siemens.com/alias/config

Siemens Aktiengesellschaft: Chairman of the Supervisory Board: Gerhard Cromme;
Managing Board: Peter Löscher, Chairman, President and Chief Executive Officer;
Johannes Feldmayer, Heinrich Hiesinger, Joe Kaeser, Rudi Lamprecht, Eduardo Montes, 
Juergen Radomski, Erich R. Reinhardt, Hermann Requardt, Uriel J. Sharef, Klaus Wucherer;
Registered offices: Berlin and Munich;
Commercial registries: Berlin Charlottenburg, HRB 12300, Munich, HRB 6684
WEEE-Reg.-No. DE 23691322

-----Original Message-----
From: Wabner, Thomas (EXT) 
Sent: Dienstag, 4. September 2007 17:54
To: commons-user@jakarta.apache.org
Subject: [commons-configuration] - overloading a properties configuration

Hi,

 

I have following problem:

 

Loading file A.property which includes follow example properties:

 

Test1=test1

Test2=test2

 

The I have a file B.property which have properties:

 

Test2=test3

 

What I want is to first load file A.properties and then "overloading" the file B.properties. The resulting configuration object should look like

 

Test1=test1

Test2=test3

 

But if I use the load() method from the PropertiesConfiguration I got a configuration object which looks like

 

Test1=test1

Test2=test2, test3

 

Now the question: If there is another method or trigger do not append the second property but to override it?

 

Many thanks

 

- waffel

Mit freundlichem Gruß / Best regards

Thomas Wabner

Siemens AG
Automation and Drives, A&D CoC Sales Configuration

SPICE - Service & Support

 

Tel.    : +49 (341) 4470-657
mailto:lpz.ipcbasis.aud@siemens.com <ma...@siemens.com> 
<http://www.siemens.com/automation> https://workspace.automation.siemens.com/alias/config <https://workspace.automation.siemens.com/alias/config> 

Siemens Aktiengesellschaft: Chairman of the Supervisory Board: Gerhard Cromme;
Managing Board: Peter Löscher, Chairman, President and Chief Executive Officer;
Johannes Feldmayer, Heinrich Hiesinger, Joe Kaeser, Rudi Lamprecht, Eduardo Montes, 
Juergen Radomski, Erich R. Reinhardt, Hermann Requardt, Uriel J. Sharef, Klaus Wucherer;
Registered offices: Berlin and Munich;
Commercial registries: Berlin Charlottenburg, HRB 12300, Munich, HRB 6684
WEEE-Reg.-No. DE 23691322

 


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


Re: [commons-configuration] - overloading a properties configuration - solved

Posted by Oliver Heger <ol...@oliver-heger.de>.
Wabner, Thomas (EXT) wrote:
> Hi again,
> 
> I have solved this problem for myself.
> 
> After reading the complete documentation I have found the ConfigurationUtils#copy() method. This method does what I want ;-)
> 
> - waffel

Hello,

ConfigurationUtils#copy() is certainly a good solution for simple use cases.

For more complex scenarios DefaultConfigurationBuilder might be an 
alternative. This class allows you to specify an arbitrary number of 
configurations to be loaded and how they should be combined. The class 
is fully covered in the user guide [1].

Oliver

[1] 
http://commons.apache.org/configuration/userguide/howto_configurationbuilder.html#Using_DefaultConfigurationBuilder

> 
> Mit freundlichem Gruß / Best regards
> 
> 
> Thomas Wabner
> 
> Siemens AG
> Automation and Drives, A&D CoC Sales Configuration
> 
> SPICE - Service & Support
>  
> Tel.    : +49 (341) 4470-657
> mailto:lpz.ipcbasis.aud@siemens.com
> https://workspace.automation.siemens.com/alias/config
> 
> Siemens Aktiengesellschaft: Chairman of the Supervisory Board: Gerhard Cromme;
> Managing Board: Peter Löscher, Chairman, President and Chief Executive Officer;
> Johannes Feldmayer, Heinrich Hiesinger, Joe Kaeser, Rudi Lamprecht, Eduardo Montes, 
> Juergen Radomski, Erich R. Reinhardt, Hermann Requardt, Uriel J. Sharef, Klaus Wucherer;
> Registered offices: Berlin and Munich;
> Commercial registries: Berlin Charlottenburg, HRB 12300, Munich, HRB 6684
> WEEE-Reg.-No. DE 23691322
> 
> -----Original Message-----
> From: Wabner, Thomas (EXT) 
> Sent: Dienstag, 4. September 2007 17:54
> To: commons-user@jakarta.apache.org
> Subject: [commons-configuration] - overloading a properties configuration
> 
> Hi,
> 
>  
> 
> I have following problem:
> 
>  
> 
> Loading file A.property which includes follow example properties:
> 
>  
> 
> Test1=test1
> 
> Test2=test2
> 
>  
> 
> The I have a file B.property which have properties:
> 
>  
> 
> Test2=test3
> 
>  
> 
> What I want is to first load file A.properties and then "overloading" the file B.properties. The resulting configuration object should look like
> 
>  
> 
> Test1=test1
> 
> Test2=test3
> 
>  
> 
> But if I use the load() method from the PropertiesConfiguration I got a configuration object which looks like
> 
>  
> 
> Test1=test1
> 
> Test2=test2, test3
> 
>  
> 
> Now the question: If there is another method or trigger do not append the second property but to override it?
> 
>  
> 
> Many thanks
> 
>  
> 
> - waffel
> 
> Mit freundlichem Gruß / Best regards
> 
> Thomas Wabner
> 
> Siemens AG
> Automation and Drives, A&D CoC Sales Configuration
> 
> SPICE - Service & Support
> 
>  
> 
> Tel.    : +49 (341) 4470-657
> mailto:lpz.ipcbasis.aud@siemens.com <ma...@siemens.com> 
> <http://www.siemens.com/automation> https://workspace.automation.siemens.com/alias/config <https://workspace.automation.siemens.com/alias/config> 
> 
> Siemens Aktiengesellschaft: Chairman of the Supervisory Board: Gerhard Cromme;
> Managing Board: Peter Löscher, Chairman, President and Chief Executive Officer;
> Johannes Feldmayer, Heinrich Hiesinger, Joe Kaeser, Rudi Lamprecht, Eduardo Montes, 
> Juergen Radomski, Erich R. Reinhardt, Hermann Requardt, Uriel J. Sharef, Klaus Wucherer;
> Registered offices: Berlin and Munich;
> Commercial registries: Berlin Charlottenburg, HRB 12300, Munich, HRB 6684
> WEEE-Reg.-No. DE 23691322
> 
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 


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