geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dain Sundstrom <>
Subject Re: [vote] XML Parsing
Date Wed, 03 Sep 2003 15:45:45 GMT
On Wednesday, September 3, 2003, at 08:07 AM, James Strachan wrote:

> On Tuesday, September 2, 2003, at 11:22  pm, Dain Sundstrom wrote:
>> On Tuesday, September 2, 2003, at 07:44 AM, James Strachan wrote:
>>> On Tuesday, September 2, 2003, at 12:56  am, Dain Sundstrom wrote:
>>>> I think we should just use Digester directly.
>>> Why?
>> The introspection makes me wary.  If they change the rules, all of 
>> our stuff breaks.
> What do you mean 'they'. We're talking about getters, setters & adder 
> methods here. I can't see the Java Beans spec changing any time soon.

By they I mean the people writing Betwixt.  You are implying there is a 
simple well understood mapping between xml and java beans.  XML names 
tend to have dashes in them and some times the structure of the (spec) 
documents is not how you want you beans.

>>  Besides that, I think the "digester glue" code you complain about 
>> below is simple to read and understand.
> Go right ahead if you want - I'm just offering us not having to write 
> 7 different digesters for the 7 J2EE schemas.

Relax James, it is not a big deal.  It is like typeing in the API 
interfaces; it is a few hours of work up front and you get a lot more 

>> What happens when you have exceptions and non trivial mappings.  For 
>> example, I have a place where I named an xml attribute named "class", 
>> but the class attribute is named "name" because the spec calls it 
>> that (and the spec is wrong).
> Betwixt just makes a special kind of Digester. Its still a Digester so 
> you can still happily add any wierd/wacky rules you want. Also for 
> doing simple property / XML changes there's a little .betwixt mapping 
> XML file you can do this with. Though I doubt we'll need to worry 
> about that - we can just code the beans right (so they use the same 
> property names as the XML elements/attributes).

That is my exact problem... In this case the beans are required by the 
JMX specification and they got the naming wrong.  The JMX spec tries to 
reuse a base class for MBeanAttributeInfo, MBeanOperationInfo and 
MBeanNotificationInfo.  They all have a field called name, which makes 
since for attribute an operation, but for notification the spec says 
that name caries the java type of the notification object.  The over 
user of inheritance here has caused the property to have the wrong 
name.  In the xml I rename the property to name as it is easier for out 
users to understand.

My guess is there will be a ton of special mappings for the j2ee specs 
as the descriptors tend to be poorly designed.

>>> Also note that Digester is read only - it cannot generate XML. 
>>> Betwixt defaults digester rules to parse XML and can generate XML 
>>> from the beans if required.
>> Cool.  Can Digester do this or does digester do something special to 
>> make it happen?
> No. Thats what betwixt is for - its the other half of digester  - to 
> allow beans to generate XML - and as an automatic way of generating 
> digester rules from  beans which use getter / setter and adder > methods.

Yes, but how does it do it.  Is it building a reverse digester using 
Digester or does it have it's own logic that knows how to do it?  I 
like that feature, but not the rest of Betwixt.


View raw message