Return-Path: Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: (qmail 12022 invoked from network); 2 Apr 2008 04:50:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Apr 2008 04:50:13 -0000 Received: (qmail 96573 invoked by uid 500); 2 Apr 2008 04:50:12 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 96497 invoked by uid 500); 2 Apr 2008 04:50:12 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 96485 invoked by uid 99); 2 Apr 2008 04:50:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Apr 2008 21:50:12 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of david.blevins@visi.com designates 208.42.176.213 as permitted sender) Received: from [208.42.176.213] (HELO g2host.com) (208.42.176.213) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Apr 2008 04:49:20 +0000 Received: from [75.161.152.126] (account dblevins@visi.com HELO [192.168.7.51]) by mailfront2.g2host.com (CommuniGate Pro SMTP 5.1.14) with ESMTPSA id 42826468 for dev@geronimo.apache.org; Tue, 01 Apr 2008 23:49:29 -0500 Message-Id: <0E3B8AC2-0169-41E3-8C44-0DA8A9E814DA@visi.com> From: David Blevins To: dev@geronimo.apache.org In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Re: Heads-up - GBeanInfo via annotations Date: Tue, 1 Apr 2008 21:49:37 -0700 References: <1206956886.2946.ezmlm@geronimo.apache.org> X-Mailer: Apple Mail (2.919.2) X-Virus-Checked: Checked by ClamAV on apache.org On Apr 1, 2008, at 1:18 AM, Gianny Damour wrote: > > On 01/04/2008, at 7:52 AM, David Blevins wrote: > >> >> On Mar 31, 2008, at 5:37 AM, Gianny Damour wrote: >>>> From: David Jencks >>>> >>>> 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. > > I do not understand. @ParameterNames' target is either a constructor > or a method. The @ParameterName I am referring to targets a > parameter. It does not mandate another annotation acting as a > wrapper to be useful. What is exactly the dead end you are hinting at? I completely forgot about the MyConstructor(@MyAnnotation String myString) possibility and was thinking about the "can't have more than one annotation on a target" limitation. >> 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. > > This idea of @Attributes(Attribute[]) or @ParameterNames may or may > not be desirable. The more parameters, the less desirable it is > (this is the point I tried to make). Let's consider how > AppClientModuleBuilder would be annotated with @ParameterNames: The inlined approach is definitely the nicer approach. I totally forgot about the ability to annotate individual parameters in the method signature. There's a sneaky way to get the param names from the debug info in the class (code is in xbean). That should allow us to extend the annotation by exception approach to constructors and factory methods (if we support them some day). I'd hope we then use the same annotation for fields methods or constructor/factoryMethod params. >> 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. > > The motivation to have all the metadata located at one spot may or > may not be desirable. As per the previous example, I believe that > putting annotations at the right place is more readable and > maintainable. As a matter of fact, I am not a fan of the static > block approach we are using to construct GBeanInfos as these blocks > are too far from the code they are describing even if all the > metadata is in one spot. I don't care for that approach myself either, just throwing it out there as something that'd be easy to support and give some style options. I can see it being a nice option in the configure by exception mindset where there might be just one annotation you need to supply and it possibly has some very long and detailed attributes that might be annoying to have in a constructor (or to repeat if there's more than one constructor). -David