commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: [betwixt] plugging in code for specific fields
Date Fri, 04 Mar 2005 00:23:18 GMT


Thanks for your respone which has pretty much confirmed that there is no
easy way to configure this. With some ingenuity? and a lot of debugging I
came up with a different solution which works though I am not sure if its
a good way to go.

FYI I noticed that there are two classes MethodExpression and MethodUpdater
which are setup in the ElementDescriptor to get data out of and put data
into fields in beans. So I plugged in my own Expression and Updater objects
using ElementDescriptor.setContextExpression    and
ElementDescriptor.setUpdater.    These classes have as memebers the
original classes in order to access the beans fields using reflection.

 thanks again


robert burrell donkin <> on 04/03/2005
12:01:44 p.m.

Please respond to "Jakarta Commons Users List"

To:    Jakarta Commons Users List <>
Subject:    Re: [betwixt] plugging in code for specific fields

On Tue, 2005-03-01 at 03:24, wrote:
> Hello


> I wish to use betwixt to dump and load objects from instances of
> application over which we have no control of the api. I can get it to
> for simple cases but I am unsure of the approach to take to customise
> behaviour in the following circumstance:

i'm not sure that there's an out-of-the-box solution (maybe it would be
a good idea to have a pluggable substitutor) but i think that you should
be able to do it with a little effort and ingenuity...

> 1) when I'm dumping out a bean to xml which includes a field which is an
> of another object , I wish to be able to plug in some code that does a
> lookup of the referenced object so that I can write out the key instead
> the id,

one approach to this would be to use a betwixt file (or any other
suitable method) to ensure that the element name is appropriate and then
use a custom ObjectStringConverter to look up the key. you'll probably
want to upgrade to a recent nightly or roll your own from CVS to take
advantage of the methods that take contexts.

> and
> 2) when I reading in that xml I wish to be able to plug in code that does
> look up with the key to recover the id.

you might be able to use the same mechanism to look up the id in this
way as well.

there are a few other ways this might be done but this seems to me the

- robert

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message