[cdi-dev] Specializing producer methods & qualifiers

Werner Keil werner.keil at gmail.com
Tue Apr 14 04:52:20 EDT 2015


Christian,

Here's a case that matches your @MyQualifier question in Agorava:
https://github.com/agorava/agorava-socializer/blob/develop/src/main/java/org/agorava/socializer/LinkedInController.java
uses:
@Inject @LinkedInprivate NetworkUpdateService updateService;

This is the @LinkedIn "MyQualifier"
https://github.com/agorava/agorava-linkedin/blob/develop/agorava-linkedin-api/src/main/java/org/agorava/linkedin/LinkedIn.java

It uses a Meta-annotation @ProviderRelated
https://github.com/agorava/agorava-core/blob/develop/agorava-core-api/src/main/java/org/agorava/api/atinject/ProviderRelated.java
to declare the service provider (like "LinkedIn" or others) but no
@Inherited.

@Antoine, good luck with the tutorial at DevoXX France and CU soon,

Werner

On Tue, Apr 14, 2015 at 8:55 AM, <cdi-dev-request at lists.jboss.org> wrote:

> Send cdi-dev mailing list submissions to
>         cdi-dev at lists.jboss.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://lists.jboss.org/mailman/listinfo/cdi-dev
> or, via email, send a message with subject or body 'help' to
>         cdi-dev-request at lists.jboss.org
>
> You can reach the person managing the list at
>         cdi-dev-owner at lists.jboss.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of cdi-dev digest..."
>
>
> Today's Topics:
>
>    1. No meeting today (Antoine Sabot-Durand)
>    2. [JBoss JIRA] (CDI-519) Instance.destroy() cannot be used for
>       dependent bean instances not created by the same Instance object
>       (Martin Kouba (JIRA))
>    3. Specializing producer methods & qualifiers (Christian Kaltepoth)
>    4. Re: Specializing producer methods & qualifiers (Jozef Hartinger)
>    5. Re: Specializing producer methods & qualifiers
>       (Christian Kaltepoth)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 7 Apr 2015 14:53:22 +0200
> From: Antoine Sabot-Durand <antoine at sabot-durand.net>
> Subject: [cdi-dev] No meeting today
> To: cdi-dev <cdi-dev at lists.jboss.org>
> Message-ID: <DAB22B90-65CE-4B50-84EC-3A718DA040FC at sabot-durand.net>
> Content-Type: text/plain; charset="utf-8"
>
> Hi all,
>
>
> I?ll be on Devoxx France rehearsal today (giving a 3 hrs university
> tomorrow) and won?t be available for the meeting.
>
> See you next week
>
> Antoine
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: signature.asc
> Type: application/pgp-signature
> Size: 495 bytes
> Desc: Message signed with OpenPGP using GPGMail
> Url :
> http://lists.jboss.org/pipermail/cdi-dev/attachments/20150407/95cc5f91/attachment-0001.bin
>
> ------------------------------
>
> Message: 2
> Date: Thu, 9 Apr 2015 05:18:18 -0400 (EDT)
> From: "Martin Kouba (JIRA)" <issues at jboss.org>
> Subject: [cdi-dev] [JBoss JIRA] (CDI-519) Instance.destroy() cannot be
>         used for dependent bean instances not created by the same Instance
>         object
> To: cdi-dev at lists.jboss.org
> Message-ID:
>         <JIRA.12567996.1428571044000.66471.1428571098459 at Atlassian.JIRA>
> Content-Type: text/plain; charset=UTF-8
>
> Martin Kouba created CDI-519:
> --------------------------------
>
>              Summary: Instance.destroy() cannot be used for dependent bean
> instances not created by the same Instance object
>                  Key: CDI-519
>                  URL: https://issues.jboss.org/browse/CDI-519
>              Project: CDI Specification Issues
>           Issue Type: Clarification
>     Affects Versions: 1.2.Final
>             Reporter: Martin Kouba
>
>
> 5.6.1. The Instance interface:
> {quote}
> The method destroy() instructs the container to destroy the instance. The
> bean instance passed to destroy() should be *a dependent scoped bean
> instance*, or...
> {quote}
>
> I think this should be more obvious. E.g. this wouldn't work correctly
> even though it doesn't violate the spec:
> {code:java}
> @Dependent
> class Bar {
> }
> class Foo {
>   @Inject
>   Instance<Bar> instance;
>   void ping() {
>     instance.destroy(CDI.current().select(Bar.class).get());
>   }
> }
> {code}
>
>
>
> --
> This message was sent by Atlassian JIRA
> (v6.3.11#6341)
>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 14 Apr 2015 06:13:01 +0200
> From: Christian Kaltepoth <christian at kaltepoth.de>
> Subject: [cdi-dev] Specializing producer methods & qualifiers
> To: cdi-dev at lists.jboss.org
> Message-ID:
>         <
> CAEXeC6yYV-NmJ35M0v8d8icjtM57Zw20EuF92Bq2jVc80EPpzQ at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hey all,
>
> I've a question regarding specializing qualified producer methods. It would
> be great to get your opinion on this.
>
> Imaging this producer method:
>
>   public class MyProducer {
>     @Produces
>     @MyQualifier
>     public Something produce() {
>       // ...
>     }
>   }
>
> Now imagine the producer method is specialized like this:
>
>   public class MyExtendedProducer extends MyProducer {
>     @Override
>     @Produces
>     @Specializes
>     public Something produce() {
>       // ...
>     }
>   }
>
> Please not that I NOT added @MyQualifier to the specializing producer
> method.
>
> Now for this injection point:
>
>   @Inject
>   @MyQualifier
>   private Something something;
>
> What is expected to happen according to the spec? Will the specialized
> producer be used or not?
>
> Thanks
>
> Christian
>
>
> --
> Christian Kaltepoth
> Blog: http://blog.kaltepoth.de/
> Twitter: http://twitter.com/chkal
> GitHub: https://github.com/chkal
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.jboss.org/pipermail/cdi-dev/attachments/20150414/023eaca3/attachment-0001.html
>
> ------------------------------
>
> Message: 4
> Date: Tue, 14 Apr 2015 08:26:11 +0200
> From: Jozef Hartinger <jharting at redhat.com>
> Subject: Re: [cdi-dev] Specializing producer methods & qualifiers
> To: Christian Kaltepoth <christian at kaltepoth.de>,
>         cdi-dev at lists.jboss.org
> Message-ID: <552CB303.1080904 at redhat.com>
> Content-Type: text/plain; charset="windows-1252"
>
> Hi Christian,
>
> yes, the specializing producer inherits all the qualifiers of the
> specialized producer. Furthermore, if the specialized producer had
> defined a name, this would have been inherited as well (even without
> explicit declaration on MyExtendedProducer.produce()). See
>
> http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#direct_and_indirect_specialization
> for details.
>
> Jozef
>
> On 04/14/2015 06:13 AM, Christian Kaltepoth wrote:
> > Hey all,
> >
> > I've a question regarding specializing qualified producer methods. It
> > would be great to get your opinion on this.
> >
> > Imaging this producer method:
> >
> >   public class MyProducer {
> >     @Produces
> >     @MyQualifier
> >     public Something produce() {
> >       // ...
> >     }
> >   }
> >
> > Now imagine the producer method is specialized like this:
> >
> >   public class MyExtendedProducer extends MyProducer {
> >     @Override
> > @Produces
> >     @Specializes
> >     public Something produce() {
> >       // ...
> >     }
> >   }
> >
> > Please not that I NOT added @MyQualifier to the specializing producer
> > method.
> >
> > Now for this injection point:
> >
> >   @Inject
> >   @MyQualifier
> >   private Something something;
> >
> > What is expected to happen according to the spec? Will the specialized
> > producer be used or not?
> >
> > Thanks
> >
> > Christian
> >
> >
> > --
> > Christian Kaltepoth
> > Blog: http://blog.kaltepoth.de/
> > Twitter: http://twitter.com/chkal
> > GitHub: https://github.com/chkal
> >
> >
> >
> > _______________________________________________
> > cdi-dev mailing list
> > cdi-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/cdi-dev
> >
> > Note that for all code provided on this list, the provider licenses the
> code under the Apache License, Version 2 (
> http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
> provided on this list, the provider waives all patent and other
> intellectual property rights inherent in such information.
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.jboss.org/pipermail/cdi-dev/attachments/20150414/25b037a6/attachment-0001.html
>
> ------------------------------
>
> Message: 5
> Date: Tue, 14 Apr 2015 08:55:39 +0200
> From: Christian Kaltepoth <christian at kaltepoth.de>
> Subject: Re: [cdi-dev] Specializing producer methods & qualifiers
> To: Jozef Hartinger <jharting at redhat.com>
> Cc: cdi-dev at lists.jboss.org
> Message-ID:
>         <CAEXeC6yno=tr=
> rm2rfg5HDap8Aw7anV9jfatSioEhbckpabuGA at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi Jozef,
>
> thanks a lot for your response. So if I read this correctly, the qualifier
> doesn't need to be annotated with @Inherited for this behavior. Is that
> correct?
>
> Christian
>
>
> 2015-04-14 8:26 GMT+02:00 Jozef Hartinger <jharting at redhat.com>:
>
> >  Hi Christian,
> >
> > yes, the specializing producer inherits all the qualifiers of the
> > specialized producer. Furthermore, if the specialized producer had
> defined
> > a name, this would have been inherited as well (even without explicit
> > declaration on MyExtendedProducer.produce()). See
> >
> http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#direct_and_indirect_specialization
> > for details.
> >
> > Jozef
> >
> >
> > On 04/14/2015 06:13 AM, Christian Kaltepoth wrote:
> >
> > Hey all,
> >
> >  I've a question regarding specializing qualified producer methods. It
> > would be great to get your opinion on this.
> >
> >  Imaging this producer method:
> >
> >    public class MyProducer {
> >     @Produces
> >     @MyQualifier
> >     public Something produce() {
> >       // ...
> >     }
> >   }
> >
> >  Now imagine the producer method is specialized like this:
> >
> >    public class MyExtendedProducer extends MyProducer {
> >     @Override
> >     @Produces
> >     @Specializes
> >     public Something produce() {
> >       // ...
> >     }
> >   }
> >
> >  Please not that I NOT added @MyQualifier to the specializing producer
> > method.
> >
> >  Now for this injection point:
> >
> >    @Inject
> >   @MyQualifier
> >   private Something something;
> >
> >  What is expected to happen according to the spec? Will the specialized
> > producer be used or not?
> >
> >  Thanks
> >
> >  Christian
> >
> >
> >  --
> >  Christian Kaltepoth
> > Blog: http://blog.kaltepoth.de/
> > Twitter: http://twitter.com/chkal
> > GitHub: https://github.com/chkal
> >
> >
> >
> > _______________________________________________
> > cdi-dev mailing listcdi-dev at lists.jboss.orghttps://
> lists.jboss.org/mailman/listinfo/cdi-dev
> >
> > Note that for all code provided on this list, the provider licenses the
> code under the Apache License, Version 2 (
> http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
> provided on this list, the provider waives all patent and other
> intellectual property rights inherent in such information.
> >
> >
> >
>
>
> --
> Christian Kaltepoth
> Blog: http://blog.kaltepoth.de/
> Twitter: http://twitter.com/chkal
> GitHub: https://github.com/chkal
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.jboss.org/pipermail/cdi-dev/attachments/20150414/289a422b/attachment.html
>
> ------------------------------
>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
>
> Note that for all code provided on this list, the provider licenses the
> code under the Apache License, Version 2 (
> http://www.apache.org/licenses/LICENSE-2.0.html).  For all other ideas
> provided on this list, the provider waives all patent and other
> intellectual property rights inherent in such information.
>
> End of cdi-dev Digest, Vol 53, Issue 11
> ***************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20150414/b31a3d28/attachment-0001.html 


More information about the cdi-dev mailing list