You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Thomas Dudziak <to...@gmail.com> on 2005/04/10 22:05:57 UTC

[betwixt] [patch] Support for polymorphic references

Hi,

attached is a patch to commons-betwixt, SVN Head, that enables betwixt
to map polymorphic references. I.e. a class has a field of a type,
that itself or some of its subtypes are mapped. This in effect makes
it necessary to make the 'name' attribute completely optional (using
the property name when necessary) in order to be able to use the
element definition from the class descriptor of the reference type.
The attached TestReferenceMapping provides a unit test for this
scenario.

Also attached is a unit test that shows a bug in betwixt for the same
scenario but with a collection (see also section "Mixed Collections -
Guessing Element Names" in
http://jakarta.apache.org/commons/betwixt/guide/binding.html).

Tom

Re: [betwixt] [patch] Support for polymorphic references

Posted by Thomas Dudziak <to...@gmail.com>.
> cool :)
> 
> one of the problems with the current code base is that there's a lot of
> stuff in transition. it can be a little confusing to find your way
> around. (it is a lot safer to develop than it used to be, though.) i'd
> to happy to try to point you in the general direction.

Ok, cool, I'll let you know when I need help :-)

Tom

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


Re: [betwixt] [patch] Support for polymorphic references

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Mon, 2005-04-18 at 22:51 +0200, Thomas Dudziak wrote:
> > i hope to be able to find some time before then.
> 
> That would be great, but please do get some sleep in between, ok ? ;-)
> Seriously though, I wouldn't mind delving deeper into betwixt myself
> anyway. There is one thing that I wanted to try out, where some deeper
> (arcane) knowledge of betwixt wouldn't hurt.

cool :)

one of the problems with the current code base is that there's a lot of
stuff in transition. it can be a little confusing to find your way
around. (it is a lot safer to develop than it used to be, though.) i'd
to happy to try to point you in the general direction.

- robert


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


Re: [betwixt] [patch] Support for polymorphic references

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Thu, 2005-04-21 at 00:11 +0200, Thomas Dudziak wrote:
> > test runs now
> 
> Great work! Will surely help me a lot.

great

> > fixed a couple of small things: need to match on singular property type
> > in the test for polymorphism. (possible may need to add an extra null
> > test and then check property type in some cases. no time to create unit
> > tests to prove or disprove this now.) also, tweaked the element name
> > matching code in the property descriptor.
> 
> What do you mean with singular property type ? A common base type
> different from Object ?

(one of the other problems with betwixt is that some of the basic
descriptor concepts are not as well described as they might be. a number
of these predate my involvement and so though i know how they're used,
i'm sometimes a little hazy about their original design purpose.)

it's to do with collectives (like collections and maps). it gives the
type of the elements contained in the collective. (the property type
will contain the actual collective type.) 

one of the weaknesses of the way that betwixt does descriptors is that
there's no way to indicate a link in the object graph without
associating an element. that makes things more complex. 

> 
> > an important thing to remember is that betwixt (right or wrong) does not
> > assign adders automatically when using a dot betwixt file. you need to
> > either use addDefaults or add an updater property. this behaviour has
> > been like this for a while and is a FAQ. maybe it needs changing but
> > that then there'd be no way to indicate no updater should be used.
> 
> Mhmm, this auto-determination of an adder/updater would be really nice
> to have. What's the reason somebody want's no updater ? If this is for
> read-only properties, then some property like "readonly" might do ?

this behaviour has been around longer than i can remember. i can't think
of any reason why anyone wouldn't want an updater unless the property is
read-only. adding a read-only property and automatically finding
updaters sounds like a much better idea :)

> Btw, does this new reference/collection behaviour affect the addDefaults stuff ?

shouldn't do. addDefaults really just runs the generic introspection
stuff to fill in anything property left unmatched. could do with a unit
test to prove it, though...

- robert


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


Re: [betwixt] [patch] Support for polymorphic references

Posted by Thomas Dudziak <to...@gmail.com>.
> test runs now

Great work! Will surely help me a lot.

> fixed a couple of small things: need to match on singular property type
> in the test for polymorphism. (possible may need to add an extra null
> test and then check property type in some cases. no time to create unit
> tests to prove or disprove this now.) also, tweaked the element name
> matching code in the property descriptor.

What do you mean with singular property type ? A common base type
different from Object ?

> an important thing to remember is that betwixt (right or wrong) does not
> assign adders automatically when using a dot betwixt file. you need to
> either use addDefaults or add an updater property. this behaviour has
> been like this for a while and is a FAQ. maybe it needs changing but
> that then there'd be no way to indicate no updater should be used.

Mhmm, this auto-determination of an adder/updater would be really nice
to have. What's the reason somebody want's no updater ? If this is for
read-only properties, then some property like "readonly" might do ?
Btw, does this new reference/collection behaviour affect the addDefaults stuff ?

regards,
Tom

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


Re: [betwixt] [patch] Support for polymorphic references

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
test runs now

fixed a couple of small things: need to match on singular property type
in the test for polymorphism. (possible may need to add an extra null
test and then check property type in some cases. no time to create unit
tests to prove or disprove this now.) also, tweaked the element name
matching code in the property descriptor.

an important thing to remember is that betwixt (right or wrong) does not
assign adders automatically when using a dot betwixt file. you need to
either use addDefaults or add an updater property. this behaviour has
been like this for a while and is a FAQ. maybe it needs changing but
that then there'd be no way to indicate no updater should be used. 

opinions? 

- robert

On Mon, 2005-04-18 at 22:51 +0200, Thomas Dudziak wrote:
> > i hope to be able to find some time before then.
> 
> That would be great, but please do get some sleep in between, ok ? ;-)
> Seriously though, I wouldn't mind delving deeper into betwixt myself
> anyway. There is one thing that I wanted to try out, where some deeper
> (arcane) knowledge of betwixt wouldn't hurt.
> 
> regards,
> Tom
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 



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


Re: [betwixt] [patch] Support for polymorphic references

Posted by Thomas Dudziak <to...@gmail.com>.
> i hope to be able to find some time before then.

That would be great, but please do get some sleep in between, ok ? ;-)
Seriously though, I wouldn't mind delving deeper into betwixt myself
anyway. There is one thing that I wanted to try out, where some deeper
(arcane) knowledge of betwixt wouldn't hurt.

regards,
Tom

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


Re: [betwixt] [patch] Support for polymorphic references

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Mon, 2005-04-18 at 22:36 +0200, Thomas Dudziak wrote:
> > had i put a little more thought before rewriting your patch, i would
> > have remembered that it's not good enough to change just the creator.
> > reading uses an action based framework to execute the binding and will
> > ignore any elements that it doesn't recognise. all that should be needed
> > is to add support for polymorphism into the appropriate action. (when
> > the descriptor is polymorphic, the action should be greedy and try to
> > create a bean for every element encountered.) it is possible that some
> > tweaks may be needed to the stack walking code in the context.
> > 
> > there a possibility that i might get round to this tonight or it might
> > be a little while. (my priority right now is fixing commons-logging.) if
> > you need it quick and have a little time, then it'd probably patchable
> > with a little debugging. (start by looking at MappingAction subclasses.)
> 
> I probably won't have time to do some more stuff with betwixt before
> the weekend anyway (I'm planning to replace the current repository
> reading mechanism in OJB with betwixt then). I could try debugging
> then if you don't have the time.

i hope to be able to find some time before then. 

- robert


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


Re: [betwixt] [patch] Support for polymorphic references

Posted by Thomas Dudziak <to...@gmail.com>.
> had i put a little more thought before rewriting your patch, i would
> have remembered that it's not good enough to change just the creator.
> reading uses an action based framework to execute the binding and will
> ignore any elements that it doesn't recognise. all that should be needed
> is to add support for polymorphism into the appropriate action. (when
> the descriptor is polymorphic, the action should be greedy and try to
> create a bean for every element encountered.) it is possible that some
> tweaks may be needed to the stack walking code in the context.
> 
> there a possibility that i might get round to this tonight or it might
> be a little while. (my priority right now is fixing commons-logging.) if
> you need it quick and have a little time, then it'd probably patchable
> with a little debugging. (start by looking at MappingAction subclasses.)

I probably won't have time to do some more stuff with betwixt before
the weekend anyway (I'm planning to replace the current repository
reading mechanism in OJB with betwixt then). I could try debugging
then if you don't have the time.

regards,
Tom

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


Re: [betwixt] [patch] Support for polymorphic references

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Sun, 2005-04-17 at 22:04 +0200, Thomas Dudziak wrote:
> Thanks for the fix!
> Collections do work also, but only in parts (or I did make a mistake
> ?). At least, I've made a mistake in the original collection test
> which I fixed and attached again (though it seems to the wrong issue,
> sorry about that, pressed the submit button to quickly). Anyway,
> writing collections work, but reading does not.

had i put a little more thought before rewriting your patch, i would
have remembered that it's not good enough to change just the creator.
reading uses an action based framework to execute the binding and will
ignore any elements that it doesn't recognise. all that should be needed
is to add support for polymorphism into the appropriate action. (when
the descriptor is polymorphic, the action should be greedy and try to
create a bean for every element encountered.) it is possible that some
tweaks may be needed to the stack walking code in the context. 

there a possibility that i might get round to this tonight or it might
be a little while. (my priority right now is fixing commons-logging.) if
you need it quick and have a little time, then it'd probably patchable
with a little debugging. (start by looking at MappingAction subclasses.)

- robert


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


Re: [betwixt] [patch] Support for polymorphic references

Posted by Thomas Dudziak <to...@gmail.com>.
Thanks for the fix!
Collections do work also, but only in parts (or I did make a mistake
?). At least, I've made a mistake in the original collection test
which I fixed and attached again (though it seems to the wrong issue,
sorry about that, pressed the submit button to quickly). Anyway,
writing collections work, but reading does not.

Tom

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


Re: [betwixt] [patch] Support for polymorphic references

Posted by Thomas Dudziak <to...@gmail.com>.
Thanks, but could it be that you forgot to add the
PolymorphicReferenceResolver to the SVN ?

regards,
Tom

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


Re: [betwixt] [patch] Support for polymorphic references

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Wed, 2005-04-13 at 22:54 +0200, Thomas Dudziak wrote:
> > sorry for ignoring so many of your posts (been very busy recently)
> 
> who isn't ;-)
>  
> > the mailing list is sometimes too aggressive when stripping attachments.
> > could you possibly create a bug report and attach all your patches to
> > it?
> 
> I'll try (though I really dislike bugzilla for its user-unfriendlyness).

thanks

AIUI it was the volume of viruses which meant the lists had to strip out
most kinds of attachments 

- robert




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


Re: [betwixt] [patch] Support for polymorphic references

Posted by Thomas Dudziak <to...@gmail.com>.
> sorry for ignoring so many of your posts (been very busy recently)

who isn't ;-)
 
> the mailing list is sometimes too aggressive when stripping attachments.
> could you possibly create a bug report and attach all your patches to
> it?

I'll try (though I really dislike bugzilla for its user-unfriendlyness).

Tom

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


Re: [betwixt] [patch] Support for polymorphic references

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Sun, 2005-04-10 at 22:05 +0200, Thomas Dudziak wrote:
> Hi,

hi Thomas

sorry for ignoring so many of your posts (been very busy recently)

<snip>

> The attached TestReferenceMapping provides a unit test for this
> scenario.

sadly the unit test attachment didn't make it through to me

> Also attached is a unit test that shows a bug in betwixt for the same
> scenario but with a collection (see also section "Mixed Collections -
> Guessing Element Names" in
> http://jakarta.apache.org/commons/betwixt/guide/binding.html).

thanks but again the unit test didn't seem to make it through

the mailing list is sometimes too aggressive when stripping attachments.
could you possibly create a bug report and attach all your patches to
it?

TIA

- robert


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