commons-user mailing list archives

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




Robert

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

Stephen






robert burrell donkin <robertburrelldonkin@blueyonder.co.uk> on 04/03/2005
12:01:44 p.m.

Please respond to "Jakarta Commons Users List"
       <commons-user@jakarta.apache.org>

To:    Jakarta Commons Users List <commons-user@jakarta.apache.org>
cc:
Subject:    Re: [betwixt] plugging in code for specific fields


On Tue, 2005-03-01 at 03:24, Stephen_Newman@bnz.co.nz wrote:
> Hello

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
work
> for simple cases but I am unsure of the approach to take to customise
it's
> 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
id
> 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
of
> 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
a
> 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
easiest.

- robert


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







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


Mime
View raw message