You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by St...@bnz.co.nz on 2005/03/01 04:24:14 UTC

[betwixt] plugging in code for specific fields




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:
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, 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.

A typical example. AccountingRuleAccountConfig  has two such fields
creditAccountId and debitAccountId -

<AccountingRuleAccountConfig id="1">
    <authName>COT/Bond Trading</authName>
    <creditAccountId>3835</creditAccountId>
    <debitAccountId>3833</debitAccountId>
    <eventType>COT</eventType>
    <id>3862</id>
......
</AccountingRuleAccountConfig >

I wish to write out something like
<creditAccountKey>PREMIUM-DISCOUNT-EARNED-PL</creditAccountKey>

regards

Stephen Newman


CAUTION - This message may contain privileged and confidential  information
intended only for the use of the addressee named above. If you are not the
intended recipient of this message you are hereby  notified that any use,
dissemination, distribution or reproduction  of this message is prohibited.
If you have received this message in  error please notify Bank of New
Zealand immediately.  Any views expressed in this message are those of the
individual  sender and may not necessarily reflect the views of Bank of
New Zealand.


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


Re: [betwixt] plugging in code for specific fields

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
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