You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Lance Semmens <la...@essential.com.au> on 2005/04/18 07:35:25 UTC

[betwixt] Custom bean creation

I'm wanting to use my own logic to instantiate beans from XML elements.
After reading the doco, it seems that the way to do this is to create a
ChainedBeanCreator and add it to the BeanCreationChain.

I am writing my own ChainedBeanCreator but I can't see how to access the
body of an XML element in the 
create(ElementMapping mapping, ReadContext context, BeanCreationChain chain)
method. 

When i say "the body of an xml element" i mean "bar" part of
"<foo>bar</foo>".

Thanks,
Lance.

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


Re: [betwixt] Custom bean creation

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Mon, 2005-04-18 at 15:05 +0930, Lance Semmens wrote:
> I'm wanting to use my own logic to instantiate beans from XML elements.
> After reading the doco, it seems that the way to do this is to create a
> ChainedBeanCreator and add it to the BeanCreationChain.
> 
> I am writing my own ChainedBeanCreator but I can't see how to access the
> body of an XML element in the 
> create(ElementMapping mapping, ReadContext context, BeanCreationChain chain)
> method. 
> 
> When i say "the body of an xml element" i mean "bar" part of
> "<foo>bar</foo>".

betwixt is sax-based. this has several implications for the
architecture. the bean creation chain stuff is intended to help solve
the problem of what object to create when faced with the initial element
info set. this would allow you to do something clever when faced with
the element <foo>. however, being SAX, you cannot read forward to find
out what the mixed content (for example 'bar') is.

a different mechanism is therefore required to support object creation
based on mixed content (or indeed, full info set). this is something
that i've wanted to add for a long time and have a good idea how to do
it but i'm unlikely to get it done any time soon. (my main priority at
the moment is fixing commons-logging which is difficult and that may
take quite a while.)

i can give you some instructions about how you can solve your the
problem in the narrow or (if you feel like contributing to betwixt), we
can talk about ways to solve this problem in the general :)

i'll leave it up to you... 

- robert 


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