You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by robert burrell donkin <ro...@blueyonder.co.uk> on 2002/11/26 20:29:51 UTC

[beanutils] Map as a pseudo-bean...? [was Re: [beanutils] PropertyUtils.setProperty on classes which extend Map]

On Monday, November 25, 2002, at 11:25 PM, Craig R. McClanahan wrote:

<snip>

> AFAIK, we've never promised that the BeanUtils or PropertyUtils code
> formally support Maps as the *destination* of a property set operation,
> even though they are acceptable as the source in certain scenarios.  In
> addition, if we're going to support setting via PropertyUtils, we
> certainly should support getting for symmetry.
>
> I think it's worth investigating whether we can support a Map as a
> pseudo-bean -- but that should start with a general analysis of the
> problem space (including the thorny issue of deciding what the "property
> type" of such a property should be if there is no current value for a
> particular key), rather than a piecemeal fix to one aspect of the
> situation.

that does seem the best approach.

> I'm game to participate (a little) in a discussion like that -- just don'
> t
> have the cycles to lead one.  Do you?

probably. i'm not sure that i've the capability, though. guess we'll have 
to wait and see about that...

just to make sure that i understand the basic concept, here's my 
restatement:

a map could act as a pseudo-bean by having each key-value pair act as a 
pseudo-property. the name of the property corresponds to the key (from the 
pair) and the property value corresponds to the value (from the pair).

- robert


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [beanutils] Map as a pseudo-bean...? [was Re: [beanutils] PropertyUtils.setProperty on classes which extend Map]

Posted by Juozas Baliuka <ba...@centras.lt>.
I have some experimental code to generate beans at runtime (BCEL stuff) :

Class cls = generate(Class[] types, String[] names);
Object bean = cls.newInstance();

But I can't find use case for it myself :)


> On Tuesday, November 26, 2002, at 08:07 PM, Juozas Baliuka wrote:
>
> > It is trivial to generate "bean" at runtime, but it can be used in
> > "untyped" languages only.
> >  Map can be used the same way, without any "adapter".
> > I think type information is useless in this case ( "script" doe's not
use
> > it ).
> > Are "dynabeans" used as some kind of workaround for "not map enabled"
> > frameworks  ?
>
> i don't how you could use them but i don't think that this is the reason
> why they were developed.
>
> AFAIK they act as adapters (for bean-centric environments) for data which
> isn't in beans. for example, they can be used to wrap a resultset so that
> it appears to be beans. if the bean-centric environment uses beanutils for
> it's introspection then the dynabean wrapping the resultset will look and
> behaviour like a bean.
>
> (i'm not a dynabeans expert so hopefully i'll be corrected if i've gone
> wrong.)
>
> - robert
>
> > ----- Original Message -----
> > From: "Stephen Colebourne" <sc...@btopenworld.com>
> > To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
> > Sent: Tuesday, November 26, 2002 9:50 PM
> > Subject: Re: [beanutils] Map as a pseudo-bean...? [was Re: [beanutils]
> > PropertyUtils.setProperty on classes which extend Map]
> >
> >
> >> From: "robert burrell donkin" <ro...@blueyonder.co.uk>
> >>> a map could act as a pseudo-bean by having each key-value pair act as
a
> >>> pseudo-property. the name of the property corresponds to the key (from
> > the
> >>> pair) and the property value corresponds to the value (from the pair).
> >>
> >> FYI, this is part of what [clazz] is trying to achieve.
> >>
> >> Stephen
> >>
> >>
> >> --
> >> To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> >> For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >>
> >
> >
> > --
> > To unsubscribe, e-mail:
<mailto:commons-dev-unsubscribe@jakarta.apache.
> > org>
> > For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.
> > org>
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [beanutils] Map as a pseudo-bean...? [was Re: [beanutils] PropertyUtils.setProperty on classes which extend Map]

Posted by robert burrell donkin <ro...@AlmostHuman.com>.
On Tuesday, November 26, 2002, at 08:07 PM, Juozas Baliuka wrote:

> It is trivial to generate "bean" at runtime, but it can be used in
> "untyped" languages only.
>  Map can be used the same way, without any "adapter".
> I think type information is useless in this case ( "script" doe's not use
> it ).
> Are "dynabeans" used as some kind of workaround for "not map enabled"
> frameworks  ?

i don't how you could use them but i don't think that this is the reason 
why they were developed.

AFAIK they act as adapters (for bean-centric environments) for data which 
isn't in beans. for example, they can be used to wrap a resultset so that 
it appears to be beans. if the bean-centric environment uses beanutils for 
it's introspection then the dynabean wrapping the resultset will look and 
behaviour like a bean.

(i'm not a dynabeans expert so hopefully i'll be corrected if i've gone 
wrong.)

- robert

> ----- Original Message -----
> From: "Stephen Colebourne" <sc...@btopenworld.com>
> To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
> Sent: Tuesday, November 26, 2002 9:50 PM
> Subject: Re: [beanutils] Map as a pseudo-bean...? [was Re: [beanutils]
> PropertyUtils.setProperty on classes which extend Map]
>
>
>> From: "robert burrell donkin" <ro...@blueyonder.co.uk>
>>> a map could act as a pseudo-bean by having each key-value pair act as a
>>> pseudo-property. the name of the property corresponds to the key (from
> the
>>> pair) and the property value corresponds to the value (from the pair).
>>
>> FYI, this is part of what [clazz] is trying to achieve.
>>
>> Stephen
>>
>>
>> --
>> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
>> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>>
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.
> org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [beanutils] Map as a pseudo-bean...? [was Re: [beanutils] PropertyUtils.setProperty on classes which extend Map]

Posted by Juozas Baliuka <ba...@centras.lt>.
It is trivial to generate "bean" at runtime, but it can be used in
"untyped" languages only.
 Map can be used the same way, without any "adapter".
I think type information is useless in this case ( "script" doe's not use
it ).
Are "dynabeans" used as some kind of workaround for "not map enabled"
frameworks  ?

----- Original Message -----
From: "Stephen Colebourne" <sc...@btopenworld.com>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Tuesday, November 26, 2002 9:50 PM
Subject: Re: [beanutils] Map as a pseudo-bean...? [was Re: [beanutils]
PropertyUtils.setProperty on classes which extend Map]


> From: "robert burrell donkin" <ro...@blueyonder.co.uk>
> > a map could act as a pseudo-bean by having each key-value pair act as a
> > pseudo-property. the name of the property corresponds to the key (from
the
> > pair) and the property value corresponds to the value (from the pair).
>
> FYI, this is part of what [clazz] is trying to achieve.
>
> Stephen
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [beanutils] Map as a pseudo-bean...? [was Re: [beanutils] PropertyUtils.setProperty on classes which extend Map]

Posted by Stephen Colebourne <sc...@btopenworld.com>.
From: "robert burrell donkin" <ro...@blueyonder.co.uk>
> a map could act as a pseudo-bean by having each key-value pair act as a
> pseudo-property. the name of the property corresponds to the key (from the
> pair) and the property value corresponds to the value (from the pair).

FYI, this is part of what [clazz] is trying to achieve.

Stephen


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>