You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Klein, Raimund" <Ra...@berenberg.de> on 2011/12/13 14:45:17 UTC

[configuration] Issues with XMLConfiguration

Hi everyone,
 
I've been playing around with configuration 1.7 for a while now, specifically XMLConfiguration (since I'm a fan of hierarchical files) and the XPathExpressionEngine. Cool stuff. :-)
 
However, I've run into two issues:
- Since my file is nested a couple of levels, I like to create configuration nodes with children myself and then add whole subtrees at the appropriate points. For the self-created nodes, I rely on org.apache.commons.configuration.tree.DefaultConfigurationNode. I also like the SubnodeConfiguration class while working on the subtree. However, I've found that when really adding new nodes to the configuration, I can't simply add them to a matching SubnodeConfiguration, as they won't be converted into XML Nodes, which causes possible ClassCastExceptions later on. Instead, I have to add them to the XMLConfiguration directly. This is due to the fact that XMLConfiguration overrides addNodes(String, Collection) and converts the nodes in the Collection into its own XML nodes; however, SubnodeConfiguration of course doesn't do this. I've been wondering whether this is intentional or maybe I'm completely missing the idea of the class SubnodeConfiguration itself. Maybe XMLConfiguration's configuration(s)At methods should return a subclass of SubnodeConfiguration which will perform the same node conversion?
 
- Is there a way to assign a formatter to changed XMLConfigurations when saving? I've found inspecting and maybe even changing the stored configuration files by hand a bit cumbersome, as there is apparently no such thing as auto-indent. As I'm expecting my files to grow over time, this would come in quite handy.
 
Other than that, I'm quite happy with what I've found so far. :-)

Mit freundlichen Grüßen / Kind regards

Raimund Klein

EDV / Software Entwickler

 

BERENBERG BANK

Joh. Berenberg, Gossler & Co. KG

Neuer Jungfernstieg 20

20354 Hamburg

 

Telefon +49 40 350 60-8129

Telefax +49 40 350 60-955

E-Mail raimund.klein@berenberg.de

www.berenberg.de <outbind://75/www.berenberg.de> 

 

Sitz: Hamburg - Amtsgericht Hamburg HRA 42659

 

Diese Nachricht einschliesslich etwa beigefuegter Anhaenge ist vertraulich und kann dem Bank- und Datengeheimnis unterliegen oder sonst rechtlich geschuetzte Daten und Informationen enthalten. Wenn Sie nicht der richtige Adressat sind oder diese Nachricht irrtuemlich erhalten haben, informieren Sie bitte sofort den Absender über die Antwortfunktion. Anschliessend moechten Sie bitte diese Nachricht einschliesslich etwa beigefuegter Anhaenge unverzueglich vollstaendig loeschen. Das unerlaubte Kopieren oder Speichern dieser Nachricht und/oder der ihr etwa beigefuegten Anhaenge sowie die unbefugte Weitergabe der darin enthaltenen Daten und Informationen sind nicht gestattet. Wir weisen darauf hin, dass rechtsverbindliche Erklaerungen namens unseres Hauses grundsaetzlich der Unterschriften zweier ausreichend bevollmaechtigter Vertreter unseres Hauses beduerfen. Wir verschicken daher keine rechtsverbindlichen Erklaerungen per E-Mail an Dritte. Demgemaess nehmen wir per E-Mail auch keine rechtsverbindlichen Erklaerungen oder Auftraege von Dritten entgegen. 
Sollten Sie Schwierigkeiten beim Oeffnen dieser E-Mail haben, wenden Sie sich bitte an den Absender oder an info@berenberg.de. Please refer to http://www.berenberg.de/my_berenberg/disclaimer_e.html for our confidentiality notice.


Re: [configuration] Issues with XMLConfiguration

Posted by Oliver Heger <ol...@oliver-heger.de>.
Hello Raimund,

many thanks for your feedback.

Am 13.12.2011 14:45, schrieb Klein, Raimund:
> Hi everyone,
>
> I've been playing around with configuration 1.7 for a while now, specifically XMLConfiguration (since I'm a fan of hierarchical files) and the XPathExpressionEngine. Cool stuff. :-)
>
> However, I've run into two issues:
> - Since my file is nested a couple of levels, I like to create configuration nodes with children myself and then add whole subtrees at the appropriate points. For the self-created nodes, I rely on org.apache.commons.configuration.tree.DefaultConfigurationNode. I also like the SubnodeConfiguration class while working on the subtree. However, I've found that when really adding new nodes to the configuration, I can't simply add them to a matching SubnodeConfiguration, as they won't be converted into XML Nodes, which causes possible ClassCastExceptions later on. Instead, I have to add them to the XMLConfiguration directly. This is due to the fact that XMLConfiguration overrides addNodes(String, Collection) and converts the nodes in the Collection into its own XML nodes; however, SubnodeConfiguration of course doesn't do this. I've been wondering whether this is intentional or maybe I'm completely missing the idea of the class SubnodeConfiguration itself. Maybe XMLConfiguration
's configuration(s)At methods should return a subclass of SubnodeConfiguration which will perform the same node conversion?

This is not by intension, it is rather a missing feature (well, maybe 
even a bug). Could you please open a ticket in our bug tracking system 
[1] for this? It's a good idea to let XMLConfiguration return a specific 
SubnodeConfiguraition with an overridden createNode() method.

>
> - Is there a way to assign a formatter to changed XMLConfigurations when saving? I've found inspecting and maybe even changing the stored configuration files by hand a bit cumbersome, as there is apparently no such thing as auto-indent. As I'm expecting my files to grow over time, this would come in quite handy.
>

Unfortunately, there is no support for formatting yet. This would 
certainly be a nice new feature. However, I am not sure what would be a 
suitable interface for such a formatter?

Thanks
Oliver

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

> Other than that, I'm quite happy with what I've found so far. :-)
>
> Mit freundlichen Grüßen / Kind regards
>
> Raimund Klein
>
> EDV / Software Entwickler
>
>
>
> BERENBERG BANK
>
> Joh. Berenberg, Gossler&  Co. KG
>
> Neuer Jungfernstieg 20
>
> 20354 Hamburg
>
>
>
> Telefon +49 40 350 60-8129
>
> Telefax +49 40 350 60-955
>
> E-Mail raimund.klein@berenberg.de
>
> www.berenberg.de<outbind://75/www.berenberg.de>
>
>
>
> Sitz: Hamburg - Amtsgericht Hamburg HRA 42659
>
>
>
> Diese Nachricht einschliesslich etwa beigefuegter Anhaenge ist vertraulich und kann dem Bank- und Datengeheimnis unterliegen oder sonst rechtlich geschuetzte Daten und Informationen enthalten. Wenn Sie nicht der richtige Adressat sind oder diese Nachricht irrtuemlich erhalten haben, informieren Sie bitte sofort den Absender über die Antwortfunktion. Anschliessend moechten Sie bitte diese Nachricht einschliesslich etwa beigefuegter Anhaenge unverzueglich vollstaendig loeschen. Das unerlaubte Kopieren oder Speichern dieser Nachricht und/oder der ihr etwa beigefuegten Anhaenge sowie die unbefugte Weitergabe der darin enthaltenen Daten und Informationen sind nicht gestattet. Wir weisen darauf hin, dass rechtsverbindliche Erklaerungen namens unseres Hauses grundsaetzlich der Unterschriften zweier ausreichend bevollmaechtigter Vertreter unseres Hauses beduerfen. Wir verschicken daher keine rechtsverbindlichen Erklaerungen per E-Mail an Dritte. Demgemaess nehmen wir per E-Mail au
ch keine rechtsverbindlichen Erklaerungen oder Auftraege von Dritten entgegen.
> Sollten Sie Schwierigkeiten beim Oeffnen dieser E-Mail haben, wenden Sie sich bitte an den Absender oder an info@berenberg.de. Please refer to http://www.berenberg.de/my_berenberg/disclaimer_e.html for our confidentiality notice.
>
>


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