On Tue, 2005-07-12 at 15:47 +0100, Ricardo Gladwell wrote:
> Hi All,

hi Ricardo

> How can I simulate this behaviour for serialisation? That is, how do I 
> force betwixt to interpret the bank account and generate an appropriate 
> country specific bank account, placing it into the bank account property 
> of the shopper, without having to create an additional bean for generic 
> bank account to hold the country-specific bank account.
> 
> Phew, I hope that is clear!

very clear, thanks :)

i think the problem is to do with dealing with the subclassing. (this is
often known as the derived beans problem.) there is some limited support
in betwixt for derived beans
(http://jakarta.apache.org/commons/betwixt/guide/derived.html) but it's
not as generic or comprehensive as it should be. unfortunately, the
current level of support won't do what you need it to do and the support
you need is unlikely to be added soon enough for you. 

so, i'm going to suggest that you adopt an approach that will work but
requires a little more work on your part. 

i suggest that you being by getting hold of the betwixt source (either
from subversion see http://jakarta.apache.org/site/cvsindex.html or from
the latest release candidate
http://people.apache.org/~rdonkin/commons-betwixt/). you need to create
a custom ChainedBeanCreator which creates the right bean based on the
element type (take a look at ChainedBeanCreatorFactory for example of
creating a bean on the basis of an attribute value) and then add it to
the chain used to create new beans (see
http://jakarta.apache.org/commons/betwixt/guide/reading.html#Reading%
20Beans%20-%20In%20Depth). though you'll have to add an entry for each
subclass, it should work.

BTW any ideas about the best way to solve (or at least, chip away at)
the general problem would be gratefully received

- robert


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to