geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: Heads-up - GBeanInfo via annotations
Date Mon, 31 Mar 2008 20:52:13 GMT

On Mar 31, 2008, at 5:37 AM, Gianny Damour wrote:
>> From: David Jencks <david_jencks@yahoo.com>
>>
>> 1. I think we should try harder to separate the identification of a  
>> constructor parameter as attribute or reference from identifying  
>> its name.  So, I think we should use the java6 and xbean  
>> @ParameterName annotations for names and something else for  
>> references if necessary.
>
> It seems to me that xbean only defines a @ParameterNames annotation,  
> which I think is quite efficient only when the number of parameters  
> is small. The need of a @ParameterName annotation, targeting a  
> parameter and not a constructor or method, really emerges when the  
> number of parameters increases.
>
> If you want, I can add a @ParameterName annotation to xbean-reflect  
> instead of adding it to geronimo-kernel.


Annotation-wise an @ParameterName annotation would only be useful if  
there was an @ParameterNames annotation to act as a wrapper (can't  
have more than one annotation of the same name on a target).  We  
already have an @ParameterNames which accepts String[] so that's sort  
of a dead end.

The "extra metadata beyond a name" aspect of constructor and factory  
method injection is certainly a tricky one.  If you can get by without  
needing anything beyond a string, that certainly makes it easier.  In  
EJB3 we're sort of hosed in that regard as we have @Resource and @EJB,  
which is nearly identical to the proposed @Attribute/@Reference  
concept; having no polymorphism in annotations makes it impossible to  
support both in a list.  If we could avoid needing the distinction,  
there are advantages.

If we do feel the need to have the distinction, I'd strongly recommend  
"reference" being a boolean type on @Attribute or some similar  
convention so there's only one annotation type which could be used in  
a list.  From there "rich" constructor or factory method support could  
be as simple as @Attributes(Attribute[]), which I'd recommend be  
supportable on a class, constructor or method.

The motivation for supporting it on a class is that there could be  
several constructors you might want usable, in which case you might be  
motivated to have all the metadata in one spot.  Ideally, if you don't  
need to explicitly add an annotation for your plain attributes and  
only require the annotation when some extra metadata is required,  
you'd only need two or three @Attribute annotations on a class.

-David



Mime
View raw message