commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver.He...@t-online.de (Oliver Heger)
Subject Re: [configuration][patch] Support for object creation
Date Tue, 07 Oct 2003 14:11:00 GMT
Eric,

I thought again about your response and now I agree with you that my code
does something which theoretically Digester could do, too. But using a
Digester object in my implementation seems to be massive overhead.

The approach with a digester friendly configuration converter is a good
idea, this would be very generic and could support many use cases including
my object creation. Unfortunately it seems to be quite difficult to
implement such a converter.

A possibility of communicating with Digester would be to let a Configuration
object trigger SAX events. Because Digester implements the
org.xml.sax.ContentHandler interface it would be able to process them (I
suppose, I didn't look at the source) . This has also the advantage of
enabling other XMLish style processing for Configuration.

My problem is now that there must be a way of extracting all available keys
from a Configuration object in the correct order to feed them into Digester.
With the actual implementation of BaseConfiguration this seems to be
impossible because all properties are simply stored in a map. Though this is
a sequenced map their original structure is lost. This is especially fatal
for XML documents whose tree like structure is messed up (maybe it is not as
problematic for plain properties or other configuration sources). A simple
example to proof this would be a document that describes database tables as
in the following fragment:

<?xml version="1.0" encoding="UTF-8"?>
<config>
 <table>
   <name>Users</name>
   <fields>
     <field>
       <name>uid</name>
       <type>long</type>
     </field>
     <field>
       <name>lastName</name>
       <type>java.lang.String</type>
     </field>
     <field>
       <name>firstName</name>
       <type>java.lang.String</type>
     </field>
   </fields>
 </table>
 <table>
   <name>documents</name>
   <fields>
     <field>
       <name>docid</name>
       <type>long</type>
     </field>
     <field>
       <name>docName</name>
       <type>java.lang.String</type>
     </field>
     <field>
       <name>authorID</name>
       <type>long</type>
     </field>
   </fields>
 </table>
</config>

After this document was parsed there is no way to find out which fields
belong to which table. Are there some plans to deal with this problem? I
think it could be worth thinking about it because XML as a configuration
format is quite important and its tree-like structure is one of its main
benefits.

If the tree structure could somehow be saved, it would also be possible to
extend the syntax of the property keys, e.g.
conf.getList("table(1).fields.field.name");
would return a vector with the names of all fields of the first table or
something like that.

Regards
Oli

----- Original Message -----
From: "Eric Pugh" <epugh@upstate.com>
To: "'Jakarta Commons Developers List'" <commons-dev@jakarta.apache.org>
Sent: Tuesday, October 07, 2003 11:30 AM
Subject: RE: [configuration][patch] Support for object creation


> Oliver..
>
> Sorry I missed your earlier post..  So, have you looked at the Digester
> commons project?  I think it does similar to what your code does..  It
takes
> in an XML file with various rules about constructores etc and then builds
> the objects from that.
>
> There is also in (I think :-) ) beanutils a simple version of Digester
that
> hides away a lot of the complexity of digester..
>
> Could you highlight how your code and digester are different? It seems
also
> that what you have done might be better applied to digester as a "simple"
> xml format..
>
> Lastly, would it make sense to write a digester friendly configuration
> converter?  In otherwords, something that would take a configuration
> objects, feed it to digester and get back objects?
>
> Eric


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


Mime
View raw message