You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by robert burrell donkin <ro...@blueyonder.co.uk> on 2003/03/13 20:31:09 UTC

Re: [Betwixt] Map of child bean

On Thursday, March 13, 2003, at 08:37 AM, Maksimenko Alexander wrote:

> From Overview
> ----сut  begin --
> Note that the .betwixt file specifies the mapping for a single bean. So, 
> whilst you can add extra elements (as above), it can't be used to specify 
> to names for child beans through nesting element elements.
> ----- cut end --
> I think that it is not comfortable.

yep. (the paragraph is telling you about a known deficiency.) it's a 
feature which needs to be added to betwixt. if this is a particular itch 
then i'd be glad to give you help if you wanted to volunteer to create a 
patch.

> For example i have two beans A and B.
> class A{
> private B initValue;
> private B finishValue;
> }
> class B{
> private int foo;
> bar int bar;
> }
> How can i map this bean at that xml file
> <a>
>  <init-b foo=".." bar="..."/>
>  <finish-b foo=".." bar="..."/>
> </a>

the first thing i need to point out is that betwixt is based on 
introspection and so deals in properties (rather than fields).

so if you have

class A
...
B getInit()
B getFinish()

then you should be able to produce the xml you need by creating a .betwixt 
file with mappings for those properties. i think you should be able to do 
something like:

<?xml version='1.0?>
<info primitiveType='attribute'>
<element name='a'>
	<element name='init-b' property='init'/>
	<element name='finish-b' property='finish'/>
</element>
</info>

if you can't make this work, post again with details of the properties and 
your betwixt file and i'll take a look in more detail.

where betwixt falls down is that you can't specify deep custom mappings 
for beans two or three levels deep in the output tree.

- robert