You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Oliver Heger <Ol...@t-online.de> on 2004/09/06 18:09:29 UTC

[configuration]Problems with XMLConfiguration

There are a couple of open issues regarding XMLConfiguration. ATM this 
class maintains a flat representation of a XML file based on a map and 
also a DOM with the hierarchical structure. When properties are added or 
removed the DOM is also updated. It seems that these update operations 
do not always work as they should.

It is surely possible to fix this and there are already some patches 
addressing some of those issues, but I ask myself do we need a flat 
representation of XML configuration files at all? 
HierarchicalXMLConfiguration already has the functionality of storing 
XML files in a hierarchical manner, so no structure is lost. The patches 
for XMLConfiguration implement functionality that 
HierarchicalXMLConfiguration already has. As it comes out 
XMLConfiguration will become a kind of HierarchicalXMLConfiguration 
(using DOM to store hierarchical structure) with an additional map for 
accessing properties.

How about removing XMLConfiguration and renaming 
HierarchicalXMLConfiguration to XMLConfiguration? This class still needs 
load() and save() methods to be compatible with the other configuration 
classes, but then it fully supports working with XML files.

Just a suggetion.
Oliver

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


Re: [configuration]Problems with XMLConfiguration

Posted by Emmanuel Bourg <sm...@lfjr.net>.
Antonio Fiol Bonnín wrote:

> How?
> 
> IIRC, only simple types can be configured, at least in Tomcat.

I don't know, but since any object can be stored in JNDI, why not a List ?


> Yes, or maybe adding a list of names in the configuration (as multiple
> properties in XML or a single comma-separated property in JNDI).

Enabling CSV values for JNDIConfiguration could be a solution, something 
like:

JNDIConfiguration config = new JNDIConfiguration();
config.setStringSplitting(true);
List list = config.getList("prop.name");

This could come with the resolution of Bug 29716.

Emmanuel Bourg



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


Re: [configuration]Problems with XMLConfiguration

Posted by Antonio Fiol Bonnín <an...@gmail.com>.
I'd be happy if it were "."

Otherwise, why would I use

prop.name.1
prop.name.2

if it were not to create a list?


Antonio Fiol

On Thu, 9 Sep 2004 10:16:22 +0000 (UTC), Henning P. Schmiedehausen
<hp...@intermeta.de> wrote:
> =?ISO-8859-1?Q?Antonio_Fiol_Bonn=EDn?= <an...@gmail.com> writes:
> 
> Just a wild thought but to solve this problem for JNDI, we could e.g.
> add a kludge to c-c which allows
> 
> xxxx_1
> xxxx_2
> xxxx_3
> 
> to be folded onto a List for get("xxxx");
> 
> Maybe using something more unique than just "_" as a marker.
> 
>         Regards
>                 Henning
> 
> 
> 
> 
> >Maybe this belongs more to -user than to -dev, but please forgive me
> >as this started here.
> 
> >> > 1.- Is it possible to have two properties at the same point? How?
> >
> >> I don't think it's possible.
> >
> >> > Otherwise, is there a point for getList with JNDI?
> >
> >> A List could be directly stored in the repository.
> 
> >How?
> 
> >IIRC, only simple types can be configured, at least in Tomcat.
> 
> >> Parsing the keys of the "conf" subset could be a solution but it's still
> >> complicated. This may be easier once we refactor the code for
> >> hierarchical configurations around the version 2.0.
> 
> >Yes, or maybe adding a list of names in the configuration (as multiple
> >properties in XML or a single comma-separated property in JNDI).
> 
> >> I'm not convinced [configuration] is the right tool for complex
> >> configurations, I tend to prefer [digester] in these cases.
> 
> >What about JNDI and mixing configuration sources? Does [digester] support those?
> 
> >Thank you very much,
> 
> >Antonio Fiol

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


Re: [configuration]Problems with XMLConfiguration

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
=?ISO-8859-1?Q?Antonio_Fiol_Bonn=EDn?= <an...@gmail.com> writes:

Just a wild thought but to solve this problem for JNDI, we could e.g.
add a kludge to c-c which allows 

xxxx_1
xxxx_2
xxxx_3

to be folded onto a List for get("xxxx");

Maybe using something more unique than just "_" as a marker. 

	Regards
		Henning


>Maybe this belongs more to -user than to -dev, but please forgive me
>as this started here.


>> > 1.- Is it possible to have two properties at the same point? How?
> 
>> I don't think it's possible.
> 
>> > Otherwise, is there a point for getList with JNDI?
> 
>> A List could be directly stored in the repository.

>How?

>IIRC, only simple types can be configured, at least in Tomcat.

>> Parsing the keys of the "conf" subset could be a solution but it's still
>> complicated. This may be easier once we refactor the code for
>> hierarchical configurations around the version 2.0.

>Yes, or maybe adding a list of names in the configuration (as multiple
>properties in XML or a single comma-separated property in JNDI).


>> I'm not convinced [configuration] is the right tool for complex
>> configurations, I tend to prefer [digester] in these cases.

>What about JNDI and mixing configuration sources? Does [digester] support those?

>Thank you very much,


>Antonio Fiol

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

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

"Fighting for one's political stand is an honorable action, but re-
 fusing to acknowledge that there might be weaknesses in one's
 position - in order to identify them so that they can be remedied -
 is a large enough problem with the Open Source movement that it
 deserves to be on this list of the top five problems."
                       -- Michelle Levesque, "Fundamental Issues with
                                    Open Source Software Development"

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


Re: [configuration]Problems with XMLConfiguration

Posted by Antonio Fiol Bonnín <an...@gmail.com>.
Maybe this belongs more to -user than to -dev, but please forgive me
as this started here.


> > 1.- Is it possible to have two properties at the same point? How?
 
> I don't think it's possible.
 
> > Otherwise, is there a point for getList with JNDI?
 
> A List could be directly stored in the repository.

How?

IIRC, only simple types can be configured, at least in Tomcat.

> Parsing the keys of the "conf" subset could be a solution but it's still
> complicated. This may be easier once we refactor the code for
> hierarchical configurations around the version 2.0.

Yes, or maybe adding a list of names in the configuration (as multiple
properties in XML or a single comma-separated property in JNDI).


> I'm not convinced [configuration] is the right tool for complex
> configurations, I tend to prefer [digester] in these cases.

What about JNDI and mixing configuration sources? Does [digester] support those?

Thank you very much,


Antonio Fiol

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


Re: [configuration]Problems with XMLConfiguration

Posted by Emmanuel Bourg <sm...@lfjr.net>.
Antonio Fiol wrote:

> So far, I'm stuck on two points with JNDI.
> 
> 1.- Is it possible to have two properties at the same point? How?

I don't think it's possible.

> Otherwise, is there a point for getList with JNDI?

A List could be directly stored in the repository.


> 
> 2.- I've seen an XML config like:
> <conf>
>   <struct name="A">
>      <prop name="p1">value1</prop>
>      <prop name="p2>value2</prop>
>   </struct>
>   <struct name="B">
>      <prop name="p1">value3</prop>
>      <prop name="p2>value4</prop>
>   </struct>
> </conf>
> 
> Then, they do things like: getList("struct[@name]")
> And they use the index to getList("struct("+i+").prop[@name]")
> And they use the index to getString("struct("+i+").prop("+j+")")
> And finally, they build a vector of hashtables, or something like that.
> 
> Well, something really horrible, IMHO.
> 
> I proposed:
> <conf>
>   <A>
>     <p1>value1</p1>
>     <p2>value2</p2>
>   </A>
> ... and so on.
> 
> This way, I remove attributes, and so I make it more compatible with
> JNDI.
> But then, how can they get the right lists to build their structures?
> Before reading the config, they do not know that "A" will be "A" and
> "B" will be "B". And there can be any number of them.

Parsing the keys of the "conf" subset could be a solution but it's still 
complicated. This may be easier once we refactor the code for 
hierarchical configurations around the version 2.0.

> Think of a log4j.properties kind of configuration, where one describes
> the "available" resources, but resources need to be built in the
> beginning so one cannot wait until the name is known.

I'm not convinced [configuration] is the right tool for complex 
configurations, I tend to prefer [digester] in these cases.

Emmanuel Bourg

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


Re: [configuration]Problems with XMLConfiguration

Posted by Antonio Fiol <an...@gmail.com>.
> Regarding hierarchical structures I even wonder if there isn't a way to
> share more code between JNDIConfiguration and
> HierarchicalConfiguration/XMLConfiguration, I feel the tree walking
> logic could be mutualized but I haven't dug this subject yet.

That sounds great! That smells great! Please tell me it is possible.

So far, I'm stuck on two points with JNDI.

1.- Is it possible to have two properties at the same point? How?

I mean: What is the JNDI equivalent for the following XML configuration file?
<conf>
  <propName>A</propName>
  <propName>B</propName>
</conf>

Otherwise, is there a point for getList with JNDI?

2.- I've seen an XML config like:
<conf>
  <struct name="A">
     <prop name="p1">value1</prop>
     <prop name="p2>value2</prop>
  </struct>
  <struct name="B">
     <prop name="p1">value3</prop>
     <prop name="p2>value4</prop>
  </struct>
</conf>

Then, they do things like: getList("struct[@name]")
And they use the index to getList("struct("+i+").prop[@name]")
And they use the index to getString("struct("+i+").prop("+j+")")
And finally, they build a vector of hashtables, or something like that.

Well, something really horrible, IMHO.

I proposed:
<conf>
  <A>
    <p1>value1</p1>
    <p2>value2</p2>
  </A>
... and so on.

This way, I remove attributes, and so I make it more compatible with JNDI.
But then, how can they get the right lists to build their structures?
Before reading the config, they do not know that "A" will be "A" and
"B" will be "B". And there can be any number of them.
Think of a log4j.properties kind of configuration, where one describes
the "available" resources, but resources need to be built in the
beginning so one cannot wait until the name is known.

Any insights?

Yours,

Antonio Fiol

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


Re: [configuration]Problems with XMLConfiguration

Posted by Emmanuel Bourg <sm...@lfjr.net>.
Oliver Heger wrote:

> Hm, I didn't think about that. Comments are not supported yet. Do you 
> think this is needed?

Well this is something I plan to do at least for PropertiesConfiguration 
(that's preserving the blank lines and the comments). For 
XMLConfiguration the comments are already in the DOM tree once the file 
is parsed, they aren't affected by the property manipulations.

Emmanuel Bourg


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


Re: [configuration]Problems with XMLConfiguration

Posted by Oliver Heger <Ol...@t-online.de>.
Emmanuel Bourg wrote:

> Oliver Heger wrote:
>
>> How about removing XMLConfiguration and renaming 
>> HierarchicalXMLConfiguration to XMLConfiguration? This class still needs
>>
>> load() and save() methods to be compatible with the other 
>> configuration classes, but then it fully supports working with XML 
>> files.
>
>
> That sounds interesting ! But will we be able to preserve XML comments ?

Hm, I didn't think about that. Comments are not supported yet. Do you 
think this is needed?

>
> Regarding hierarchical structures I even wonder if there isn't a way 
> to share more code between JNDIConfiguration and 
> HierarchicalConfiguration/XMLConfiguration, I feel the tree walking 
> logic could be mutualized but I haven't dug this subject yet.

Yes, this is probably possible. I was also thinking about extracting the 
code that evaluates expressions for querying properties, so that for 
instance an XPath engine could be plugged in. This engine - if it once 
exists - could then be used for all configuration classes.

Oliver

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


Re: [configuration]Problems with XMLConfiguration

Posted by Emmanuel Bourg <sm...@lfjr.net>.
Oliver Heger wrote:

> How about removing XMLConfiguration and renaming 
> HierarchicalXMLConfiguration to XMLConfiguration? This class still needs
> 
> load() and save() methods to be compatible with the other configuration 
> classes, but then it fully supports working with XML files.

That sounds interesting ! But will we be able to preserve XML comments ?

Regarding hierarchical structures I even wonder if there isn't a way to 
share more code between JNDIConfiguration and 
HierarchicalConfiguration/XMLConfiguration, I feel the tree walking 
logic could be mutualized but I haven't dug this subject yet.

Emmanuel Bourg


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