From john.d.ament at gmail.com Fri Aug 4 05:42:24 2017 From: john.d.ament at gmail.com (John D. Ament) Date: Fri, 04 Aug 2017 09:42:24 +0000 Subject: [weld-dev] Do Custom implementations of Bean need to provide injection points? Message-ID: Hi As the subject says. I have a library that registers a custom implementation of Bean, which has a method @Override public Set getInjectionPoints() { return Collections.emptySet(); } When testing this on Weld3, I have code that looks up the injection point, to find the annotations present. However, the following injection point lookup fails: private static InjectionPoint findInjectionPoint(final BeanManager bm, final CreationalContext ctx) { return InjectionPoint.class.cast( bm.getReference(bm.resolve(bm.getBeans(InjectionPoint.class)), InjectionPoint.class, ctx)); } so based on a CreationalContext I'm looking for InjectionPoint. Maybe there's a different way that this is supposed to work? If you're interested in giving it a shot, take a look at https://github.com/apache/geronimo-config and run the Weld3 profile to replicate the issue. John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20170804/2e7feef7/attachment.html From mkouba at redhat.com Fri Aug 4 07:05:25 2017 From: mkouba at redhat.com (Martin Kouba) Date: Fri, 4 Aug 2017 13:05:25 +0200 Subject: [weld-dev] Do Custom implementations of Bean need to provide injection points? In-Reply-To: References: Message-ID: Hi John, Bean.getInjectionPoints() is only used during validation - returned injection points are validated at initialization time, so for a custom bean it makes sense to return an empty set as there are no real injection points. WRT lookup - what exactly do you try to accomplish? Do you try to obtain InjectionPoint metadata from inside a custom dependent bean's create() method? This should be possible although not clearly specified. I think we have a test with BeanManager.getInjectableReference(InjectionPoint, CreationalContext) but I will need to double check. I will also look at the geronimo-config repo. Martin Dne 4.8.2017 v 11:42 John D. Ament napsal(a): > Hi > > As the subject says. I have a library that registers a custom > implementation of Bean, which has a method > > @Override > public Set getInjectionPoints() { > return Collections.emptySet(); > } > > When testing this on Weld3, I have code that looks up the injection > point, to find the annotations present. However, the following > injection point lookup fails: > > private static InjectionPoint findInjectionPoint(final BeanManager > bm, final CreationalContext ctx) { > return InjectionPoint.class.cast( > > bm.getReference(bm.resolve(bm.getBeans(InjectionPoint.class)), > InjectionPoint.class, ctx)); > } > > so based on a CreationalContext I'm looking for InjectionPoint. Maybe > there's a different way that this is supposed to work? If you're > interested in giving it a shot, take a look at > https://github.com/apache/geronimo-config and run the Weld3 profile to > replicate the issue. > > John > > > _______________________________________________ > weld-dev mailing list > weld-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/weld-dev > -- Martin Kouba Senior Software Engineer Red Hat, Czech Republic From mkouba at redhat.com Fri Aug 4 08:07:17 2017 From: mkouba at redhat.com (Martin Kouba) Date: Fri, 4 Aug 2017 14:07:17 +0200 Subject: [weld-dev] Do Custom implementations of Bean need to provide injection points? In-Reply-To: References: Message-ID: <20d1f460-7f2c-b896-44df-928e4208c084@redhat.com> Hm, I think BeanManager.getReference() should not be used here, see also 6.5.3. Contextual reference for a bean [1]: "The container must ensure that every injection point of type InjectionPoint and qualifier @Default of any dependent object instantiated during this process receives a null value if it is not being injected into any injection point." However, in Weld you could use BeanManager.getInjectableReference(InjectionPoint, CreationalContext) and provide some dummy IP. See for example https://github.com/weld/core/blob/master/tests-arquillian/src/test/java/org/jboss/weld/tests/injectionPoint/custom/BarBean.java#L50. FYI there is a TCK test that verifies the InjectionPoint is null if using getReference() outside custom bean's create: org.jboss.cdi.tck.tests.lookup.injectionpoint.InjectionPointTest#testNullInjectionPointInjectedIntoNonInjectedObject() Martin [1] http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#contextual_reference Dne 4.8.2017 v 13:05 Martin Kouba napsal(a): > Hi John, > > Bean.getInjectionPoints() is only used during validation - returned > injection points are validated at initialization time, so for a custom > bean it makes sense to return an empty set as there are no real > injection points. > > WRT lookup - what exactly do you try to accomplish? Do you try to obtain > InjectionPoint metadata from inside a custom dependent bean's create() > method? This should be possible although not clearly specified. I think > we have a test with BeanManager.getInjectableReference(InjectionPoint, > CreationalContext) but I will need to double check. > > I will also look at the geronimo-config repo. > > Martin > > Dne 4.8.2017 v 11:42 John D. Ament napsal(a): >> Hi >> >> As the subject says. I have a library that registers a custom >> implementation of Bean, which has a method >> >> @Override >> public Set getInjectionPoints() { >> return Collections.emptySet(); >> } >> >> When testing this on Weld3, I have code that looks up the injection >> point, to find the annotations present. However, the following >> injection point lookup fails: >> >> private static InjectionPoint findInjectionPoint(final >> BeanManager bm, final CreationalContext ctx) { >> return InjectionPoint.class.cast( >> bm.getReference(bm.resolve(bm.getBeans(InjectionPoint.class)), >> InjectionPoint.class, ctx)); >> } >> >> so based on a CreationalContext I'm looking for InjectionPoint. Maybe >> there's a different way that this is supposed to work? If you're >> interested in giving it a shot, take a look at >> https://github.com/apache/geronimo-config and run the Weld3 profile to >> replicate the issue. >> >> John >> >> >> _______________________________________________ >> weld-dev mailing list >> weld-dev at lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/weld-dev >> > -- Martin Kouba Senior Software Engineer Red Hat, Czech Republic From john.d.ament at gmail.com Fri Aug 4 08:35:26 2017 From: john.d.ament at gmail.com (John D. Ament) Date: Fri, 04 Aug 2017 12:35:26 +0000 Subject: [weld-dev] Do Custom implementations of Bean need to provide injection points? In-Reply-To: <20d1f460-7f2c-b896-44df-928e4208c084@redhat.com> References: <20d1f460-7f2c-b896-44df-928e4208c084@redhat.com> Message-ID: Martin, Knowing that I don't have any reference to an injection point, what would you recommend I pass in as a dummy injection point? John On Fri, Aug 4, 2017 at 8:07 AM Martin Kouba wrote: > Hm, I think BeanManager.getReference() should not be used here, see also > 6.5.3. Contextual reference for a bean [1]: > > "The container must ensure that every injection point of type > InjectionPoint and qualifier @Default of any dependent object > instantiated during this process receives a null value if it is not > being injected into any injection point." > > However, in Weld you could use > BeanManager.getInjectableReference(InjectionPoint, CreationalContext) > and provide some dummy IP. See for example > > https://github.com/weld/core/blob/master/tests-arquillian/src/test/java/org/jboss/weld/tests/injectionPoint/custom/BarBean.java#L50 > . > > FYI there is a TCK test that verifies the InjectionPoint is null if > using getReference() outside custom bean's create: > > org.jboss.cdi.tck.tests.lookup.injectionpoint.InjectionPointTest#testNullInjectionPointInjectedIntoNonInjectedObject() > > Martin > > [1] > http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#contextual_reference > > Dne 4.8.2017 v 13:05 Martin Kouba napsal(a): > > Hi John, > > > > Bean.getInjectionPoints() is only used during validation - returned > > injection points are validated at initialization time, so for a custom > > bean it makes sense to return an empty set as there are no real > > injection points. > > > > WRT lookup - what exactly do you try to accomplish? Do you try to obtain > > InjectionPoint metadata from inside a custom dependent bean's create() > > method? This should be possible although not clearly specified. I think > > we have a test with BeanManager.getInjectableReference(InjectionPoint, > > CreationalContext) but I will need to double check. > > > > I will also look at the geronimo-config repo. > > > > Martin > > > > Dne 4.8.2017 v 11:42 John D. Ament napsal(a): > >> Hi > >> > >> As the subject says. I have a library that registers a custom > >> implementation of Bean, which has a method > >> > >> @Override > >> public Set getInjectionPoints() { > >> return Collections.emptySet(); > >> } > >> > >> When testing this on Weld3, I have code that looks up the injection > >> point, to find the annotations present. However, the following > >> injection point lookup fails: > >> > >> private static InjectionPoint findInjectionPoint(final > >> BeanManager bm, final CreationalContext ctx) { > >> return InjectionPoint.class.cast( > >> bm.getReference(bm.resolve(bm.getBeans(InjectionPoint.class)), > >> InjectionPoint.class, ctx)); > >> } > >> > >> so based on a CreationalContext I'm looking for InjectionPoint. Maybe > >> there's a different way that this is supposed to work? If you're > >> interested in giving it a shot, take a look at > >> https://github.com/apache/geronimo-config and run the Weld3 profile to > >> replicate the issue. > >> > >> John > >> > >> > >> _______________________________________________ > >> weld-dev mailing list > >> weld-dev at lists.jboss.org > >> https://lists.jboss.org/mailman/listinfo/weld-dev > >> > > > > -- > Martin Kouba > Senior Software Engineer > Red Hat, Czech Republic > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20170804/49cae50d/attachment.html From mkouba at redhat.com Fri Aug 4 08:48:49 2017 From: mkouba at redhat.com (Martin Kouba) Date: Fri, 4 Aug 2017 14:48:49 +0200 Subject: [weld-dev] Do Custom implementations of Bean need to provide injection points? In-Reply-To: References: <20d1f460-7f2c-b896-44df-928e4208c084@redhat.com> Message-ID: <5d19f29f-24d4-6523-3742-bf1df480efbf@redhat.com> Something like this should do the trick: new InjectionPoint() { @Override public boolean isTransient() { return false; } @Override public boolean isDelegate() { return false; } @Override public Type getType() { return InjectionPoint.class; } @Override public Set getQualifiers() { return Collections. singleton(new AnnotationLiteral() {}); } @Override public Member getMember() { return null; } @Override public Bean getBean() { return this; } @Override public Annotated getAnnotated() { return null; } }; Martin Dne 4.8.2017 v 14:35 John D. Ament napsal(a): > Martin, > > Knowing that I don't have any reference to an injection point, what > would you recommend I pass in as a dummy injection point? > > John > > On Fri, Aug 4, 2017 at 8:07 AM Martin Kouba > wrote: > > Hm, I think BeanManager.getReference() should not be used here, see also > 6.5.3. Contextual reference for a bean [1]: > > "The container must ensure that every injection point of type > InjectionPoint and qualifier @Default of any dependent object > instantiated during this process receives a null value if it is not > being injected into any injection point." > > However, in Weld you could use > BeanManager.getInjectableReference(InjectionPoint, CreationalContext) > and provide some dummy IP. See for example > https://github.com/weld/core/blob/master/tests-arquillian/src/test/java/org/jboss/weld/tests/injectionPoint/custom/BarBean.java#L50. > > FYI there is a TCK test that verifies the InjectionPoint is null if > using getReference() outside custom bean's create: > org.jboss.cdi.tck.tests.lookup.injectionpoint.InjectionPointTest#testNullInjectionPointInjectedIntoNonInjectedObject() > > Martin > > [1] > http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#contextual_reference > > Dne 4.8.2017 v 13:05 Martin Kouba napsal(a): > > Hi John, > > > > Bean.getInjectionPoints() is only used during validation - returned > > injection points are validated at initialization time, so for a > custom > > bean it makes sense to return an empty set as there are no real > > injection points. > > > > WRT lookup - what exactly do you try to accomplish? Do you try to > obtain > > InjectionPoint metadata from inside a custom dependent bean's > create() > > method? This should be possible although not clearly specified. I > think > > we have a test with > BeanManager.getInjectableReference(InjectionPoint, > > CreationalContext) but I will need to double check. > > > > I will also look at the geronimo-config repo. > > > > Martin > > > > Dne 4.8.2017 v 11:42 John D. Ament napsal(a): > >> Hi > >> > >> As the subject says. I have a library that registers a custom > >> implementation of Bean, which has a method > >> > >> @Override > >> public Set getInjectionPoints() { > >> return Collections.emptySet(); > >> } > >> > >> When testing this on Weld3, I have code that looks up the injection > >> point, to find the annotations present. However, the following > >> injection point lookup fails: > >> > >> private static InjectionPoint findInjectionPoint(final > >> BeanManager bm, final CreationalContext ctx) { > >> return InjectionPoint.class.cast( > >> bm.getReference(bm.resolve(bm.getBeans(InjectionPoint.class)), > >> InjectionPoint.class, ctx)); > >> } > >> > >> so based on a CreationalContext I'm looking for InjectionPoint. > Maybe > >> there's a different way that this is supposed to work? If you're > >> interested in giving it a shot, take a look at > >> https://github.com/apache/geronimo-config and run the Weld3 > profile to > >> replicate the issue. > >> > >> John > >> > >> > >> _______________________________________________ > >> weld-dev mailing list > >> weld-dev at lists.jboss.org > >> https://lists.jboss.org/mailman/listinfo/weld-dev > >> > > > > -- > Martin Kouba > Senior Software Engineer > Red Hat, Czech Republic > -- Martin Kouba Senior Software Engineer Red Hat, Czech Republic From BENJAMIC at uk.ibm.com Wed Aug 9 05:52:13 2017 From: BENJAMIC at uk.ibm.com (Benjamin Confino) Date: Wed, 9 Aug 2017 09:52:13 +0000 Subject: [weld-dev] Dependent Scoped bean aquired by CDI.current() is not destroyed Message-ID: Hello I have a servlet that acquires two instances of a dependent scoped bean. The first is aquired by @Inject Instance the second is acquired via CDI.current().select(CdiBean.class).get(). I can see that the first instance's @PreDestroy is called when I shut down the application. However @PreDestroy is not called on the instance acquired CDI.current. Here is the source: My question is, is this behaviour intentional? And if it is, can you please link me to the appropriate part of the spec that says when we should expect a @Dependent bean created by CDI.current to be destroyed? I have a customer concerned about this causing a potential memory leak. Regards Benjamin Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20170809/41fc5f05/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: TestServlet.java Type: application/octet-stream Size: 1130 bytes Desc: not available Url : http://lists.jboss.org/pipermail/weld-dev/attachments/20170809/41fc5f05/attachment.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: CdiBean.java Type: application/octet-stream Size: 699 bytes Desc: not available Url : http://lists.jboss.org/pipermail/weld-dev/attachments/20170809/41fc5f05/attachment-0001.obj From mkouba at redhat.com Wed Aug 9 06:41:55 2017 From: mkouba at redhat.com (Martin Kouba) Date: Wed, 9 Aug 2017 12:41:55 +0200 Subject: [weld-dev] Dependent Scoped bean aquired by CDI.current() is not destroyed In-Reply-To: References: Message-ID: <831e7dae-9708-4333-d37a-82b668d948e6@redhat.com> Hi Benjamin, the lifecycle of @Dependent instances created through javax.enterprise.inject.spi.CDI is not well defined. So it's always better to destroy such instances when not needed. However, it would make sense to destroy such instances during shutdown. I believe this works in Weld SE. What environment/runtime do you use? Martin Dne 9.8.2017 v 11:52 Benjamin Confino napsal(a): > Hello > > I have a servlet that acquires two instances of a dependent scoped bean. > The first is aquired by @Inject Instance the second is acquired > via CDI.current().select(CdiBean.class).get(). > > I can see that the first instance's @PreDestroy is called when I shut > down the application. However @PreDestroy is not called on the instance > acquired CDI.current. Here is the source: > > > > My question is, is this behaviour intentional? And if it is, can you > please link me to the appropriate part of the spec that says when we > should expect a @Dependent bean created by CDI.current to be destroyed? > I have a customer concerned about this causing a potential memory leak. > > Regards > Benjamin > Unless stated otherwise above: > IBM United Kingdom Limited - Registered in England and Wales with number > 741598. > Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU > > > _______________________________________________ > weld-dev mailing list > weld-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/weld-dev > -- Martin Kouba Senior Software Engineer Red Hat, Czech Republic From mkouba at redhat.com Wed Aug 9 07:21:29 2017 From: mkouba at redhat.com (Martin Kouba) Date: Wed, 9 Aug 2017 13:21:29 +0200 Subject: [weld-dev] Dependent Scoped bean aquired by CDI.current() is not destroyed In-Reply-To: <831e7dae-9708-4333-d37a-82b668d948e6@redhat.com> References: <831e7dae-9708-4333-d37a-82b668d948e6@redhat.com> Message-ID: <8425fd03-5ac4-bcc0-2629-c8fcc1dee3b4@redhat.com> FYI I've created https://issues.jboss.org/browse/WELD-2413 Martin Dne 9.8.2017 v 12:41 Martin Kouba napsal(a): > Hi Benjamin, > > the lifecycle of @Dependent instances created through > javax.enterprise.inject.spi.CDI is not well defined. So it's always > better to destroy such instances when not needed. However, it would make > sense to destroy such instances during shutdown. > > I believe this works in Weld SE. What environment/runtime do you use? > > Martin > > Dne 9.8.2017 v 11:52 Benjamin Confino napsal(a): >> Hello >> >> I have a servlet that acquires two instances of a dependent scoped >> bean. The first is aquired by @Inject Instance the second is >> acquired via CDI.current().select(CdiBean.class).get(). >> >> I can see that the first instance's @PreDestroy is called when I shut >> down the application. However @PreDestroy is not called on the >> instance acquired CDI.current. Here is the source: >> >> >> >> My question is, is this behaviour intentional? And if it is, can you >> please link me to the appropriate part of the spec that says when we >> should expect a @Dependent bean created by CDI.current to be >> destroyed? I have a customer concerned about this causing a potential >> memory leak. >> >> Regards >> Benjamin >> Unless stated otherwise above: >> IBM United Kingdom Limited - Registered in England and Wales with >> number 741598. >> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 >> 3AU >> >> >> _______________________________________________ >> weld-dev mailing list >> weld-dev at lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/weld-dev >> > -- Martin Kouba Senior Software Engineer Red Hat, Czech Republic From BENJAMIC at uk.ibm.com Wed Aug 9 11:09:42 2017 From: BENJAMIC at uk.ibm.com (Benjamin Confino) Date: Wed, 9 Aug 2017 16:09:42 +0100 Subject: [weld-dev] Dependent Scoped bean aquired by CDI.current() is not destroyed In-Reply-To: <831e7dae-9708-4333-d37a-82b668d948e6@redhat.com> References: <831e7dae-9708-4333-d37a-82b668d948e6@redhat.com> Message-ID: Hello Martin I use weld 2.4; I tested this in liberty and wildfly-10.1.0.Final Regards Benjamin From: Martin Kouba To: Benjamin Confino , weld-dev at lists.jboss.org, Cc: Emily Jiang Date: 09/08/2017 11:42 Subject: Re: [weld-dev] Dependent Scoped bean aquired by CDI.current() is not destroyed Hi Benjamin, the lifecycle of @Dependent instances created through javax.enterprise.inject.spi.CDI is not well defined. So it's always better to destroy such instances when not needed. However, it would make sense to destroy such instances during shutdown. I believe this works in Weld SE. What environment/runtime do you use? Martin Dne 9.8.2017 v 11:52 Benjamin Confino napsal(a): > Hello > > I have a servlet that acquires two instances of a dependent scoped bean. > The first is aquired by @Inject Instance the second is acquired > via CDI.current().select(CdiBean.class).get(). > > I can see that the first instance's @PreDestroy is called when I shut > down the application. However @PreDestroy is not called on the instance > acquired CDI.current. Here is the source: > > > > My question is, is this behaviour intentional? And if it is, can you > please link me to the appropriate part of the spec that says when we > should expect a @Dependent bean created by CDI.current to be destroyed? > I have a customer concerned about this causing a potential memory leak. > > Regards > Benjamin > Unless stated otherwise above: > IBM United Kingdom Limited - Registered in England and Wales with number > 741598. > Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU > > > _______________________________________________ > weld-dev mailing list > weld-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/weld-dev > -- Martin Kouba Senior Software Engineer Red Hat, Czech Republic Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20170809/fe45aab5/attachment.html From manovotn at redhat.com Thu Aug 24 12:36:02 2017 From: manovotn at redhat.com (Matej Novotny) Date: Thu, 24 Aug 2017 12:36:02 -0400 (EDT) Subject: [weld-dev] Weld 3.0.1.Final released In-Reply-To: <2142058757.1522703.1503592510496.JavaMail.zimbra@redhat.com> Message-ID: <83784987.1522811.1503592562354.JavaMail.zimbra@redhat.com> Hey, folks! Weld 3.0.1.Final is released. Feel free to check Weld website for further information - http://weld.cdi-spec.org/news/2017/08/25/weld-301Final/ -- Novotny Matej Red Hat Czech From arjan.tijms at gmail.com Thu Aug 24 17:38:13 2017 From: arjan.tijms at gmail.com (arjan tijms) Date: Thu, 24 Aug 2017 23:38:13 +0200 Subject: [weld-dev] Weld 3.0.1.Final released In-Reply-To: <83784987.1522811.1503592562354.JavaMail.zimbra@redhat.com> References: <2142058757.1522703.1503592510496.JavaMail.zimbra@redhat.com> <83784987.1522811.1503592562354.JavaMail.zimbra@redhat.com> Message-ID: >Every Weld-enhanced object (subclass/proxy) will not implement Should that be "will now implement"? On Thu, Aug 24, 2017 at 6:36 PM, Matej Novotny wrote: > Hey, folks! > > Weld 3.0.1.Final is released. > Feel free to check Weld website for further information - > http://weld.cdi-spec.org/news/2017/08/25/weld-301Final/ > > -- > Novotny Matej > Red Hat Czech > _______________________________________________ > weld-dev mailing list > weld-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/weld-dev > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20170824/fe2559ef/attachment-0001.html From manovotn at redhat.com Mon Aug 28 03:06:05 2017 From: manovotn at redhat.com (Matej Novotny) Date: Mon, 28 Aug 2017 03:06:05 -0400 (EDT) Subject: [weld-dev] Weld 3.0.1.Final released In-Reply-To: References: <2142058757.1522703.1503592510496.JavaMail.zimbra@redhat.com> <83784987.1522811.1503592562354.JavaMail.zimbra@redhat.com> Message-ID: <427657507.2527746.1503903965515.JavaMail.zimbra@redhat.com> Yep, my bad. It should indeed be "will now implement" :) Matej ----- Original Message ----- > From: "arjan tijms" > To: "Matej Novotny" > Cc: "Weld" , dev at deltaspike.apache.org > Sent: Thursday, August 24, 2017 11:38:13 PM > Subject: Re: [weld-dev] Weld 3.0.1.Final released > > >Every Weld-enhanced object (subclass/proxy) will not implement > > Should that be "will now implement"? > > On Thu, Aug 24, 2017 at 6:36 PM, Matej Novotny wrote: > > > Hey, folks! > > > > Weld 3.0.1.Final is released. > > Feel free to check Weld website for further information - > > http://weld.cdi-spec.org/news/2017/08/25/weld-301Final/ > > > > -- > > Novotny Matej > > Red Hat Czech > > _______________________________________________ > > weld-dev mailing list > > weld-dev at lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/weld-dev > > > From ooo_saturn7 at mail.ru Tue Aug 29 07:46:23 2017 From: ooo_saturn7 at mail.ru (=?UTF-8?B?QWxleCBTdmlyaWRvdg==?=) Date: Tue, 29 Aug 2017 14:46:23 +0300 Subject: [weld-dev] =?utf-8?q?How_to_make_method_injection_when_bean_subcl?= =?utf-8?q?ass_is_required_in_Weld=3F?= Message-ID: <1504007183.617130319@f465.i.mail.ru> Hi all, I am really sorry for writing to this mailing list, but I checked all user forums and chats and saw that they are very old. I would be very thankful if someone gives suggestion for solving the following problem. I have a child and parent class. Child has SimpleFoo, Parent needs Advaced foo. So, @Dependent public class SimpleFoo { } @Dependent public class AdvancedFoo extends SimpleFoo { } @Dependent public class Child { ??? private SimpleFoo foo; ??? @Inject ??? protected void setFoo(SimpleFoo foo) { ??????? this.foo = foo; ??? } } @Dependent public class Parent extends Child { ??? @Inject ??? @Override ??? protected void setFoo(SimpleFoo foo) { //How to inject here AdvancedFoo? ??????? super.setFoo(foo); ??? } } How to inject in Parent AdvancedFoo? I know that I can do it via constructor injection but I need method injection. How to do it? Can it be done without using names (like MyBean1) but only using classes (AdvancedFoo)? Best regards, Alex -- Alex Sviridov -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20170829/0ca9c466/attachment.html From manovotn at redhat.com Tue Aug 29 09:09:19 2017 From: manovotn at redhat.com (Matej Novotny) Date: Tue, 29 Aug 2017 09:09:19 -0400 (EDT) Subject: [weld-dev] How to make method injection when bean subclass is required in Weld? In-Reply-To: <1504007183.617130319@f465.i.mail.ru> References: <1504007183.617130319@f465.i.mail.ru> Message-ID: <305673011.3125546.1504012159897.JavaMail.zimbra@redhat.com> Hi Alex, no need to be sorry, you have come to the right place :) As for your question, the simplest thing is probably to use qualifiers. Create your own like this: @Qualifier @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.TYPE, ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD }) public @interface MyQualifier {} And then change your AdvancedFoo class to use the qualifier: @Dependent @MyQualifier public class AdvancedFoo extends SimpleFoo { } And accordingly, the init method which uses injection should then look like this: @Dependent public class Parent extends Child { @Inject @Override protected void setFoo(@MyQualifier SimpleFoo foo) { super.setFoo(foo); } } Does this answer your question? Matej ----- Original Message ----- > From: "Alex Sviridov" > To: "weld-dev" > Sent: Tuesday, August 29, 2017 1:46:23 PM > Subject: [weld-dev] How to make method injection when bean subclass is required in Weld? > > Hi all, > > I am really sorry for writing to this mailing list, but I checked all user > forums and chats and saw that they are very old. > > I would be very thankful if someone gives suggestion for solving the > following problem. > I have a child and parent class. Child has SimpleFoo, Parent needs Advaced > foo. So, > > @Dependent > public class SimpleFoo { > } > > @Dependent > public class AdvancedFoo extends SimpleFoo { > } > > @Dependent > public class Child { > > private SimpleFoo foo; > > @Inject > protected void setFoo(SimpleFoo foo) { > this.foo = foo; > } > } > > @Dependent > public class Parent extends Child { > > @Inject > @Override > protected void setFoo(SimpleFoo foo) { //How to inject here AdvancedFoo? > super.setFoo(foo); > } > } > > How to inject in Parent AdvancedFoo? I know that I can do it via constructor > injection > but I need method injection. How to do it? Can it be done without using names > (like MyBean1) > but only using classes (AdvancedFoo)? > > Best regards, Alex > > > > > > -- > Alex Sviridov > > _______________________________________________ > weld-dev mailing list > weld-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/weld-dev From mkouba at redhat.com Tue Aug 29 11:22:18 2017 From: mkouba at redhat.com (Martin Kouba) Date: Tue, 29 Aug 2017 17:22:18 +0200 Subject: [weld-dev] How to make method injection when bean subclass is required in Weld? In-Reply-To: <305673011.3125546.1504012159897.JavaMail.zimbra@redhat.com> References: <1504007183.617130319@f465.i.mail.ru> <305673011.3125546.1504012159897.JavaMail.zimbra@redhat.com> Message-ID: Hi Alex, that's an interesting question. Indeed, qualifiers are the way to go if you need to keep the method signature. Another way could be to override the setFoo() method so that the Child initializer is ignored and add a new method to inject AdvancedFoo: @Override protected void setFoo(SimpleFoo foo) { // Do nothing } @Inject void setAdvancedFoo(AdvancedFoo foo) { super.setFoo(foo); } However, note that right now there are the following beans: SimpleFoo with bean types Object, SimpleFoo AdvancedFoo -> Object, SimpleFoo, AdvancedFoo So if you do @Inject SimpleFoo you get ambiguous dependency exception because both SimpleFoo and AdvancedFoo are eligible for injection. To resolve this you need to use qualifiers or restrict the bean types of AdvancedFoo: @Typed(AdvancedFoo.class) class AdvancedFoo extends SimpleFoo {} HTH Martin Dne 29.8.2017 v 15:09 Matej Novotny napsal(a): > Hi Alex, > > no need to be sorry, you have come to the right place :) > As for your question, the simplest thing is probably to use qualifiers. > > Create your own like this: > > @Qualifier > @Retention(RetentionPolicy.RUNTIME) > @Target({ ElementType.TYPE, ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD }) > public @interface MyQualifier {} > > > And then change your AdvancedFoo class to use the qualifier: > > @Dependent > @MyQualifier > public class AdvancedFoo extends SimpleFoo { > } > > And accordingly, the init method which uses injection should then look like this: > > @Dependent > public class Parent extends Child { > > @Inject > @Override > protected void setFoo(@MyQualifier SimpleFoo foo) { > super.setFoo(foo); > } > } > > Does this answer your question? > > Matej > > ----- Original Message ----- >> From: "Alex Sviridov" >> To: "weld-dev" >> Sent: Tuesday, August 29, 2017 1:46:23 PM >> Subject: [weld-dev] How to make method injection when bean subclass is required in Weld? >> >> Hi all, >> >> I am really sorry for writing to this mailing list, but I checked all user >> forums and chats and saw that they are very old. >> >> I would be very thankful if someone gives suggestion for solving the >> following problem. >> I have a child and parent class. Child has SimpleFoo, Parent needs Advaced >> foo. So, >> >> @Dependent >> public class SimpleFoo { >> } >> >> @Dependent >> public class AdvancedFoo extends SimpleFoo { >> } >> >> @Dependent >> public class Child { >> >> private SimpleFoo foo; >> >> @Inject >> protected void setFoo(SimpleFoo foo) { >> this.foo = foo; >> } >> } >> >> @Dependent >> public class Parent extends Child { >> >> @Inject >> @Override >> protected void setFoo(SimpleFoo foo) { //How to inject here AdvancedFoo? >> super.setFoo(foo); >> } >> } >> >> How to inject in Parent AdvancedFoo? I know that I can do it via constructor >> injection >> but I need method injection. How to do it? Can it be done without using names >> (like MyBean1) >> but only using classes (AdvancedFoo)? >> >> Best regards, Alex >> >> >> >> >> >> -- >> Alex Sviridov >> >> _______________________________________________ >> weld-dev mailing list >> weld-dev at lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/weld-dev > _______________________________________________ > weld-dev mailing list > weld-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/weld-dev > -- Martin Kouba Senior Software Engineer Red Hat, Czech Republic From ooo_saturn7 at mail.ru Tue Aug 29 12:16:51 2017 From: ooo_saturn7 at mail.ru (=?UTF-8?B?QWxleCBTdmlyaWRvdg==?=) Date: Tue, 29 Aug 2017 19:16:51 +0300 Subject: [weld-dev] =?utf-8?q?How_to_make_method_injection_when_bean_subcl?= =?utf-8?q?ass_is_required_in_Weld=3F?= In-Reply-To: References: <1504007183.617130319@f465.i.mail.ru> <305673011.3125546.1504012159897.JavaMail.zimbra@redhat.com> Message-ID: <1504023411.80452424@f118.i.mail.ru> Hi Martin, hi Matej, Thank you very much for your suggestions. Best regards, Alex >???????, 29 ??????? 2017, 18:22 +03:00 ?? Martin Kouba : > >Hi Alex, > >that's an interesting question. Indeed, qualifiers are the way to go if >you need to keep the method signature. > >Another way could be to override the setFoo() method so that the Child >initializer is ignored and add a new method to inject AdvancedFoo: > >@Override >protected void setFoo(SimpleFoo foo) { // Do nothing } > >@Inject >void setAdvancedFoo(AdvancedFoo foo) { >???super.setFoo(foo); >} > >However, note that right now there are the following beans: > >SimpleFoo with bean types Object, SimpleFoo >AdvancedFoo -> Object, SimpleFoo, AdvancedFoo > >So if you do @Inject SimpleFoo you get ambiguous dependency exception >because both SimpleFoo and AdvancedFoo are eligible for injection. > >To resolve this you need to use qualifiers or restrict the bean types of >AdvancedFoo: > >@Typed(AdvancedFoo.class) >class AdvancedFoo extends SimpleFoo {} > >HTH > >Martin > > >Dne 29.8.2017 v 15:09 Matej Novotny napsal(a): >> Hi Alex, >> >> no need to be sorry, you have come to the right place :) >> As for your question, the simplest thing is probably to use qualifiers. >> >> Create your own like this: >> >> @Qualifier >> @Retention(RetentionPolicy.RUNTIME) >> @Target({ ElementType.TYPE, ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD }) >> public @interface MyQualifier {} >> >> >> And then change your AdvancedFoo class to use the qualifier: >> >> @Dependent >> @MyQualifier >> public class AdvancedFoo extends SimpleFoo { >> } >> >> And accordingly, the init method which uses injection should then look like this: >> >> @Dependent >> public class Parent extends Child { >> >> @Inject >> @Override >> protected void setFoo(@MyQualifier SimpleFoo foo) { >> super.setFoo(foo); >> } >> } >> >> Does this answer your question? >> >> Matej >> >> ----- Original Message ----- >>> From: "Alex Sviridov" < ooo_saturn7 at mail.ru > >>> To: "weld-dev" < weld-dev at lists.jboss.org > >>> Sent: Tuesday, August 29, 2017 1:46:23 PM >>> Subject: [weld-dev] How to make method injection when bean subclass is required in Weld? >>> >>> Hi all, >>> >>> I am really sorry for writing to this mailing list, but I checked all user >>> forums and chats and saw that they are very old. >>> >>> I would be very thankful if someone gives suggestion for solving the >>> following problem. >>> I have a child and parent class. Child has SimpleFoo, Parent needs Advaced >>> foo. So, >>> >>> @Dependent >>> public class SimpleFoo { >>> } >>> >>> @Dependent >>> public class AdvancedFoo extends SimpleFoo { >>> } >>> >>> @Dependent >>> public class Child { >>> >>> private SimpleFoo foo; >>> >>> @Inject >>> protected void setFoo(SimpleFoo foo) { >>> this.foo = foo; >>> } >>> } >>> >>> @Dependent >>> public class Parent extends Child { >>> >>> @Inject >>> @Override >>> protected void setFoo(SimpleFoo foo) { //How to inject here AdvancedFoo? >>> super.setFoo(foo); >>> } >>> } >>> >>> How to inject in Parent AdvancedFoo? I know that I can do it via constructor >>> injection >>> but I need method injection. How to do it? Can it be done without using names >>> (like MyBean1) >>> but only using classes (AdvancedFoo)? >>> >>> Best regards, Alex >>> >>> >>> >>> >>> >>> -- >>> Alex Sviridov >>> >>> _______________________________________________ >>> weld-dev mailing list >>> weld-dev at lists.jboss.org >>> https://lists.jboss.org/mailman/listinfo/weld-dev >> _______________________________________________ >> weld-dev mailing list >> weld-dev at lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/weld-dev >> > >-- >Martin Kouba >Senior Software Engineer >Red Hat, Czech Republic -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20170829/21250f42/attachment-0001.html From ooo_saturn7 at mail.ru Tue Aug 29 14:54:47 2017 From: ooo_saturn7 at mail.ru (=?UTF-8?B?QWxleCBTdmlyaWRvdg==?=) Date: Tue, 29 Aug 2017 21:54:47 +0300 Subject: [weld-dev] =?utf-8?q?How_to_make_method_injection_when_bean_subcl?= =?utf-8?q?ass_is_required_in_Weld=3F?= In-Reply-To: References: <1504007183.617130319@f465.i.mail.ru> <305673011.3125546.1504012159897.JavaMail.zimbra@redhat.com> Message-ID: <1504032887.173818615@f467.i.mail.ru> I thought here, and would like to share my ideas hoping to get comments from more experienced people. First of all I came to conclusion that CDI works badly with cases when we need to change field values in super classes. If there is a lot of inheritance as in my case: ParentA, ChildA0, ChildA1.., ParentB, ChildB0, ChildB1..,... then situation is becoming very bad. Maybe in future there will be other solutions in CDI specs. I found two additional ways that can be used. 1) Inject not beans but instances, + method SimpleFoo newFoo {return Instance.get} + overriding. 2) Inject BeanManager + method SimpleFoo newFoo() {beanManager...} + overriding. Maybe such ways can be named lazy/postponed initialization with overriding support.... Best regards, Alex >???????, 29 ??????? 2017, 18:22 +03:00 ?? Martin Kouba : > >Hi Alex, > >that's an interesting question. Indeed, qualifiers are the way to go if >you need to keep the method signature. > >Another way could be to override the setFoo() method so that the Child >initializer is ignored and add a new method to inject AdvancedFoo: > >@Override >protected void setFoo(SimpleFoo foo) { // Do nothing } > >@Inject >void setAdvancedFoo(AdvancedFoo foo) { >???super.setFoo(foo); >} > >However, note that right now there are the following beans: > >SimpleFoo with bean types Object, SimpleFoo >AdvancedFoo -> Object, SimpleFoo, AdvancedFoo > >So if you do @Inject SimpleFoo you get ambiguous dependency exception >because both SimpleFoo and AdvancedFoo are eligible for injection. > >To resolve this you need to use qualifiers or restrict the bean types of >AdvancedFoo: > >@Typed(AdvancedFoo.class) >class AdvancedFoo extends SimpleFoo {} > >HTH > >Martin > > >Dne 29.8.2017 v 15:09 Matej Novotny napsal(a): >> Hi Alex, >> >> no need to be sorry, you have come to the right place :) >> As for your question, the simplest thing is probably to use qualifiers. >> >> Create your own like this: >> >> @Qualifier >> @Retention(RetentionPolicy.RUNTIME) >> @Target({ ElementType.TYPE, ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD }) >> public @interface MyQualifier {} >> >> >> And then change your AdvancedFoo class to use the qualifier: >> >> @Dependent >> @MyQualifier >> public class AdvancedFoo extends SimpleFoo { >> } >> >> And accordingly, the init method which uses injection should then look like this: >> >> @Dependent >> public class Parent extends Child { >> >> @Inject >> @Override >> protected void setFoo(@MyQualifier SimpleFoo foo) { >> super.setFoo(foo); >> } >> } >> >> Does this answer your question? >> >> Matej >> >> ----- Original Message ----- >>> From: "Alex Sviridov" < ooo_saturn7 at mail.ru > >>> To: "weld-dev" < weld-dev at lists.jboss.org > >>> Sent: Tuesday, August 29, 2017 1:46:23 PM >>> Subject: [weld-dev] How to make method injection when bean subclass is required in Weld? >>> >>> Hi all, >>> >>> I am really sorry for writing to this mailing list, but I checked all user >>> forums and chats and saw that they are very old. >>> >>> I would be very thankful if someone gives suggestion for solving the >>> following problem. >>> I have a child and parent class. Child has SimpleFoo, Parent needs Advaced >>> foo. So, >>> >>> @Dependent >>> public class SimpleFoo { >>> } >>> >>> @Dependent >>> public class AdvancedFoo extends SimpleFoo { >>> } >>> >>> @Dependent >>> public class Child { >>> >>> private SimpleFoo foo; >>> >>> @Inject >>> protected void setFoo(SimpleFoo foo) { >>> this.foo = foo; >>> } >>> } >>> >>> @Dependent >>> public class Parent extends Child { >>> >>> @Inject >>> @Override >>> protected void setFoo(SimpleFoo foo) { //How to inject here AdvancedFoo? >>> super.setFoo(foo); >>> } >>> } >>> >>> How to inject in Parent AdvancedFoo? I know that I can do it via constructor >>> injection >>> but I need method injection. How to do it? Can it be done without using names >>> (like MyBean1) >>> but only using classes (AdvancedFoo)? >>> >>> Best regards, Alex >>> >>> >>> >>> >>> >>> -- >>> Alex Sviridov >>> >>> _______________________________________________ >>> weld-dev mailing list >>> weld-dev at lists.jboss.org >>> https://lists.jboss.org/mailman/listinfo/weld-dev >> _______________________________________________ >> weld-dev mailing list >> weld-dev at lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/weld-dev >> > >-- >Martin Kouba >Senior Software Engineer >Red Hat, Czech Republic -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20170829/bbdd29d1/attachment.html From manovotn at redhat.com Wed Aug 30 03:51:29 2017 From: manovotn at redhat.com (Matej Novotny) Date: Wed, 30 Aug 2017 03:51:29 -0400 (EDT) Subject: [weld-dev] How to make method injection when bean subclass is required in Weld? In-Reply-To: <1504032887.173818615@f467.i.mail.ru> References: <1504007183.617130319@f465.i.mail.ru> <305673011.3125546.1504012159897.JavaMail.zimbra@redhat.com> <1504032887.173818615@f467.i.mail.ru> Message-ID: <1940358553.3434727.1504079489009.JavaMail.zimbra@redhat.com> 1) If you inject Instance, you still have the ambiguous dependency issue for any class which does have a subclass. E.g. from your sample: @Inject Instance instance; //within some method instance.get(); -> this will blow up because you have two beans which have SimpleFoo type (SimpleFoo and AdvancedFoo) 2) I don't understand what you mean by this. How does BM help here? Sidenote: You might want to try and use what Martin said - limiting the types of a bean with @Typed(MyClass.Foo). That way you have control over the bean types and can further manupulate the injection. Limit all your children to only the actual subclass type they have: @Dependent @Typed(AdvancedFoo.class) public class AdvancedFoo extends SimpleFoo { // this ben now only has a bean of AdvancedFoo, e.g. it does not fit into injection point for SimpleFoo } And then override the initializer methods like this: @Dependent public class Parent extends Child { @Inject @Override protected void setFoo(AdvancedFoo foo) { this.foo = foo; // assuming foo is a protected field } } Matej ----- Original Message ----- > From: "Alex Sviridov" > To: "weld-dev" > Sent: Tuesday, August 29, 2017 8:54:47 PM > Subject: Re: [weld-dev] How to make method injection when bean subclass is required in Weld? > > I thought here, and would like to share my ideas hoping to get comments from > more experienced people. > > First of all I came to conclusion that CDI works badly with cases when we > need > to change field values in super classes. If there is a lot of inheritance as > in my case: > ParentA, ChildA0, ChildA1.., ParentB, ChildB0, ChildB1..,... then situation > is > becoming very bad. Maybe in future there will be other solutions in CDI > specs. > > I found two additional ways that can be used. 1) Inject not beans but > instances, > + method SimpleFoo newFoo {return Instance.get} + overriding. > 2) Inject BeanManager + method SimpleFoo newFoo() {beanManager...} + > overriding. > > Maybe such ways can be named lazy/postponed initialization with overriding > support.... > > Best regards, Alex > > > > > ???????, 29 ??????? 2017, 18:22 +03:00 ?? Martin Kouba : > > Hi Alex, > > that's an interesting question. Indeed, qualifiers are the way to go if > you need to keep the method signature. > > Another way could be to override the setFoo() method so that the Child > initializer is ignored and add a new method to inject AdvancedFoo: > > @Override > protected void setFoo(SimpleFoo foo) { // Do nothing } > > @Inject > void setAdvancedFoo(AdvancedFoo foo) { > super.setFoo(foo); > } > > However, note that right now there are the following beans: > > SimpleFoo with bean types Object, SimpleFoo > AdvancedFoo -> Object, SimpleFoo, AdvancedFoo > > So if you do @Inject SimpleFoo you get ambiguous dependency exception > because both SimpleFoo and AdvancedFoo are eligible for injection. > > To resolve this you need to use qualifiers or restrict the bean types of > AdvancedFoo: > > @Typed(AdvancedFoo.class) > class AdvancedFoo extends SimpleFoo {} > > HTH > > Martin > > > Dne 29.8.2017 v 15:09 Matej Novotny napsal(a): > > Hi Alex, > > > > no need to be sorry, you have come to the right place :) > > As for your question, the simplest thing is probably to use qualifiers. > > > > Create your own like this: > > > > @Qualifier > > @Retention(RetentionPolicy.RUNTIME) > > @Target({ ElementType.TYPE, ElementType.PARAMETER, ElementType.FIELD, > > ElementType.METHOD }) > > public @interface MyQualifier {} > > > > > > And then change your AdvancedFoo class to use the qualifier: > > > > @Dependent > > @MyQualifier > > public class AdvancedFoo extends SimpleFoo { > > } > > > > And accordingly, the init method which uses injection should then look like > > this: > > > > @Dependent > > public class Parent extends Child { > > > > @Inject > > @Override > > protected void setFoo(@MyQualifier SimpleFoo foo) { > > super.setFoo(foo); > > } > > } > > > > Does this answer your question? > > > > Matej > > > > ----- Original Message ----- > >> From: "Alex Sviridov" < ooo_saturn7 at mail.ru > > >> To: "weld-dev" < weld-dev at lists.jboss.org > > >> Sent: Tuesday, August 29, 2017 1:46:23 PM > >> Subject: [weld-dev] How to make method injection when bean subclass is > >> required in Weld? > >> > >> Hi all, > >> > >> I am really sorry for writing to this mailing list, but I checked all user > >> forums and chats and saw that they are very old. > >> > >> I would be very thankful if someone gives suggestion for solving the > >> following problem. > >> I have a child and parent class. Child has SimpleFoo, Parent needs Advaced > >> foo. So, > >> > >> @Dependent > >> public class SimpleFoo { > >> } > >> > >> @Dependent > >> public class AdvancedFoo extends SimpleFoo { > >> } > >> > >> @Dependent > >> public class Child { > >> > >> private SimpleFoo foo; > >> > >> @Inject > >> protected void setFoo(SimpleFoo foo) { > >> this.foo = foo; > >> } > >> } > >> > >> @Dependent > >> public class Parent extends Child { > >> > >> @Inject > >> @Override > >> protected void setFoo(SimpleFoo foo) { //How to inject here AdvancedFoo? > >> super.setFoo(foo); > >> } > >> } > >> > >> How to inject in Parent AdvancedFoo? I know that I can do it via > >> constructor > >> injection > >> but I need method injection. How to do it? Can it be done without using > >> names > >> (like MyBean1) > >> but only using classes (AdvancedFoo)? > >> > >> Best regards, Alex > >> > >> > >> > >> > >> > >> -- > >> Alex Sviridov > >> > >> _______________________________________________ > >> weld-dev mailing list > >> weld-dev at lists.jboss.org > >> https://lists.jboss.org/mailman/listinfo/weld-dev > > _______________________________________________ > > weld-dev mailing list > > weld-dev at lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/weld-dev > > > > -- > Martin Kouba > Senior Software Engineer > Red Hat, Czech Republic > > > _______________________________________________ > weld-dev mailing list > weld-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/weld-dev From ooo_saturn7 at mail.ru Wed Aug 30 05:10:27 2017 From: ooo_saturn7 at mail.ru (=?UTF-8?B?QWxleCBTdmlyaWRvdg==?=) Date: Wed, 30 Aug 2017 12:10:27 +0300 Subject: [weld-dev] =?utf-8?q?How_to_make_method_injection_when_bean_subcl?= =?utf-8?q?ass_is_required_in_Weld=3F?= In-Reply-To: <1940358553.3434727.1504079489009.JavaMail.zimbra@redhat.com> References: <1504007183.617130319@f465.i.mail.ru> <1504032887.173818615@f467.i.mail.ru> <1940358553.3434727.1504079489009.JavaMail.zimbra@redhat.com> Message-ID: <1504084227.775212976@f378.i.mail.ru> Hi Matej, I meant the following (in previous example I had a mistake - called Parent Child and Child Parent) , now without this mistake: 1) public class Parent { ??? @Inject ??? private Instance fooInstance; ??? private SimpleFoo foo; ??? protected SimpleFoo newFoo() { ????????? return fooInstance.get(); ??? } ??? @PostConstruct ??? private void doPostConstruct() { ??????? foo = newFoo(); ??? } } public class Child extends Parent { ??? @Inject ??? private Instance fooInstance; ??? @Override ??? protected AdvancedFoo newFoo() { ????????? return fooInstance.get(); ??? } } 2) ? public class Parent { ??? @Inject ??? protected BeanManager beanManager; ??? private SimpleFoo foo; ??? protected SimpleFoo newFoo() { ????????? SimpleFoo foo = constructing bean with BM; ? ? ? ? ? return foo; ??? } ??? @PostConstruct ??? private void doPostConstruct() { ??????? foo = newFoo(); ??? } } public class Child extends Parent { ??? @Override ??? protected AdvancedFoo newFoo() { ????????? AdvancedFoo foo = constructing bean with BM; ? ? ? ? ? return foo; ??? } } Thank you for your explanation of Typed. I got it. Best regards, Alex >?????, 30 ??????? 2017, 10:51 +03:00 ?? Matej Novotny : > >1) If you inject Instance, you still have the ambiguous dependency issue for any class which does have a subclass. >E.g. from your sample: > >@Inject >Instance instance; > >//within some method >instance.get(); -> this will blow up because you have two beans which have SimpleFoo type (SimpleFoo and AdvancedFoo) > >2) I don't understand what you mean by this. How does BM help here? > > >Sidenote: >You might want to try and use what Martin said - limiting the types of a bean with @Typed(MyClass.Foo). >That way you have control over the bean types and can further manupulate the injection. >Limit all your children to only the actual subclass type they have: > >@Dependent >@Typed(AdvancedFoo.class) >public class AdvancedFoo extends SimpleFoo { >?// this ben now only has a bean of AdvancedFoo, e.g. it does not fit into injection point for SimpleFoo >} > >And then override the initializer methods like this: > >@Dependent >public class Parent extends Child { >? >??@Inject >??@Override >??protected void setFoo(AdvancedFoo foo) { >???this.foo = foo; // assuming foo is a protected field >??} >} > >Matej > > >----- Original Message ----- >> From: "Alex Sviridov" < ooo_saturn7 at mail.ru > >> To: "weld-dev" < weld-dev at lists.jboss.org > >> Sent: Tuesday, August 29, 2017 8:54:47 PM >> Subject: Re: [weld-dev] How to make method injection when bean subclass is required in Weld? >> >> I thought here, and would like to share my ideas hoping to get comments from >> more experienced people. >> >> First of all I came to conclusion that CDI works badly with cases when we >> need >> to change field values in super classes. If there is a lot of inheritance as >> in my case: >> ParentA, ChildA0, ChildA1.., ParentB, ChildB0, ChildB1..,... then situation >> is >> becoming very bad. Maybe in future there will be other solutions in CDI >> specs. >> >> I found two additional ways that can be used. 1) Inject not beans but >> instances, >> + method SimpleFoo newFoo {return Instance.get} + overriding. >> 2) Inject BeanManager + method SimpleFoo newFoo() {beanManager...} + >> overriding. >> >> Maybe such ways can be named lazy/postponed initialization with overriding >> support.... >> >> Best regards, Alex >> >> >> >> >> ???????, 29 ??????? 2017, 18:22 +03:00 ?? Martin Kouba < mkouba at redhat.com >: >> >> Hi Alex, >> >> that's an interesting question. Indeed, qualifiers are the way to go if >> you need to keep the method signature. >> >> Another way could be to override the setFoo() method so that the Child >> initializer is ignored and add a new method to inject AdvancedFoo: >> >> @Override >> protected void setFoo(SimpleFoo foo) { // Do nothing } >> >> @Inject >> void setAdvancedFoo(AdvancedFoo foo) { >> super.setFoo(foo); >> } >> >> However, note that right now there are the following beans: >> >> SimpleFoo with bean types Object, SimpleFoo >> AdvancedFoo -> Object, SimpleFoo, AdvancedFoo >> >> So if you do @Inject SimpleFoo you get ambiguous dependency exception >> because both SimpleFoo and AdvancedFoo are eligible for injection. >> >> To resolve this you need to use qualifiers or restrict the bean types of >> AdvancedFoo: >> >> @Typed(AdvancedFoo.class) >> class AdvancedFoo extends SimpleFoo {} >> >> HTH >> >> Martin >> >> >> Dne 29.8.2017 v 15:09 Matej Novotny napsal(a): >> > Hi Alex, >> > >> > no need to be sorry, you have come to the right place :) >> > As for your question, the simplest thing is probably to use qualifiers. >> > >> > Create your own like this: >> > >> > @Qualifier >> > @Retention(RetentionPolicy.RUNTIME) >> > @Target({ ElementType.TYPE, ElementType.PARAMETER, ElementType.FIELD, >> > ElementType.METHOD }) >> > public @interface MyQualifier {} >> > >> > >> > And then change your AdvancedFoo class to use the qualifier: >> > >> > @Dependent >> > @MyQualifier >> > public class AdvancedFoo extends SimpleFoo { >> > } >> > >> > And accordingly, the init method which uses injection should then look like >> > this: >> > >> > @Dependent >> > public class Parent extends Child { >> > >> > @Inject >> > @Override >> > protected void setFoo(@MyQualifier SimpleFoo foo) { >> > super.setFoo(foo); >> > } >> > } >> > >> > Does this answer your question? >> > >> > Matej >> > >> > ----- Original Message ----- >> >> From: "Alex Sviridov" < ooo_saturn7 at mail.ru > >> >> To: "weld-dev" < weld-dev at lists.jboss.org > >> >> Sent: Tuesday, August 29, 2017 1:46:23 PM >> >> Subject: [weld-dev] How to make method injection when bean subclass is >> >> required in Weld? >> >> >> >> Hi all, >> >> >> >> I am really sorry for writing to this mailing list, but I checked all user >> >> forums and chats and saw that they are very old. >> >> >> >> I would be very thankful if someone gives suggestion for solving the >> >> following problem. >> >> I have a child and parent class. Child has SimpleFoo, Parent needs Advaced >> >> foo. So, >> >> >> >> @Dependent >> >> public class SimpleFoo { >> >> } >> >> >> >> @Dependent >> >> public class AdvancedFoo extends SimpleFoo { >> >> } >> >> >> >> @Dependent >> >> public class Child { >> >> >> >> private SimpleFoo foo; >> >> >> >> @Inject >> >> protected void setFoo(SimpleFoo foo) { >> >> this.foo = foo; >> >> } >> >> } >> >> >> >> @Dependent >> >> public class Parent extends Child { >> >> >> >> @Inject >> >> @Override >> >> protected void setFoo(SimpleFoo foo) { //How to inject here AdvancedFoo? >> >> super.setFoo(foo); >> >> } >> >> } >> >> >> >> How to inject in Parent AdvancedFoo? I know that I can do it via >> >> constructor >> >> injection >> >> but I need method injection. How to do it? Can it be done without using >> >> names >> >> (like MyBean1) >> >> but only using classes (AdvancedFoo)? >> >> >> >> Best regards, Alex >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> Alex Sviridov >> >> >> >> _______________________________________________ >> >> weld-dev mailing list >> >> weld-dev at lists.jboss.org >> >> https://lists.jboss.org/mailman/listinfo/weld-dev >> > _______________________________________________ >> > weld-dev mailing list >> > weld-dev at lists.jboss.org >> > https://lists.jboss.org/mailman/listinfo/weld-dev >> > >> >> -- >> Martin Kouba >> Senior Software Engineer >> Red Hat, Czech Republic >> >> >> _______________________________________________ >> weld-dev mailing list >> weld-dev at lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/weld-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20170830/714edc35/attachment-0001.html From manovotn at redhat.com Wed Aug 30 05:45:07 2017 From: manovotn at redhat.com (Matej Novotny) Date: Wed, 30 Aug 2017 05:45:07 -0400 (EDT) Subject: [weld-dev] How to make method injection when bean subclass is required in Weld? In-Reply-To: <1504084227.775212976@f378.i.mail.ru> References: <1504007183.617130319@f465.i.mail.ru> <1504032887.173818615@f467.i.mail.ru> <1940358553.3434727.1504079489009.JavaMail.zimbra@redhat.com> <1504084227.775212976@f378.i.mail.ru> Message-ID: <294704991.3480211.1504086307456.JavaMail.zimbra@redhat.com> Hi Alex What you suggest will inevitably fail for the reasons we mentioned previously. Both approaches will try to resolve a bean of type SimpleFoo which is ambiguous. Furthermore, doing `foo = new Foo()` is like saying "goodbye CDI". If you do this, you control the lifecycle of such object, not CDI. Therefore, there will be no injection done into such object, neither will CDI be able to dispose of such object. Matej ----- Original Message ----- > From: "Alex Sviridov" > To: "weld-dev" > Sent: Wednesday, August 30, 2017 11:10:27 AM > Subject: Re: [weld-dev] How to make method injection when bean subclass is required in Weld? > > > > Hi Matej, > > I meant the following (in previous example I had a mistake - called Parent > Child and Child Parent) > , now without this mistake: > 1) > public class Parent { > > @Inject > private Instance fooInstance; > > private SimpleFoo foo; > > protected SimpleFoo newFoo() { > return fooInstance.get(); > } > > @PostConstruct > private void doPostConstruct() { > foo = newFoo(); > } > } > > public class Child extends Parent { > > @Inject > private Instance fooInstance; > > @Override > protected AdvancedFoo newFoo() { > return fooInstance.get(); > } > } > > > 2) > > public class Parent { > > @Inject > protected BeanManager beanManager; > > private SimpleFoo foo; > > protected SimpleFoo newFoo() { > SimpleFoo foo = constructing bean with BM; > return foo; > } > > @PostConstruct > private void doPostConstruct() { > foo = newFoo(); > } > } > > public class Child extends Parent { > > @Override > protected AdvancedFoo newFoo() { > AdvancedFoo foo = constructing bean with BM; > return foo; > } > } > > Thank you for your explanation of Typed. I got it. > > Best regards, Alex > > > ?????, 30 ??????? 2017, 10:51 +03:00 ?? Matej Novotny : > > 1) If you inject Instance, you still have the ambiguous dependency issue > for any class which does have a subclass. > E.g. from your sample: > > @Inject > Instance instance; > > //within some method > instance.get(); -> this will blow up because you have two beans which have > SimpleFoo type (SimpleFoo and AdvancedFoo) > > 2) I don't understand what you mean by this. How does BM help here? > > > Sidenote: > You might want to try and use what Martin said - limiting the types of a bean > with @Typed(MyClass.Foo). > That way you have control over the bean types and can further manupulate the > injection. > Limit all your children to only the actual subclass type they have: > > @Dependent > @Typed(AdvancedFoo.class) > public class AdvancedFoo extends SimpleFoo { > // this ben now only has a bean of AdvancedFoo, e.g. it does not fit into > injection point for SimpleFoo > } > > And then override the initializer methods like this: > > @Dependent > public class Parent extends Child { > > @Inject > @Override > protected void setFoo(AdvancedFoo foo) { > this.foo = foo; // assuming foo is a protected field > } > } > > Matej > > > ----- Original Message ----- > > From: "Alex Sviridov" < ooo_saturn7 at mail.ru > > > To: "weld-dev" < weld-dev at lists.jboss.org > > > Sent: Tuesday, August 29, 2017 8:54:47 PM > > Subject: Re: [weld-dev] How to make method injection when bean subclass is > > required in Weld? > > > > I thought here, and would like to share my ideas hoping to get comments > > from > > more experienced people. > > > > First of all I came to conclusion that CDI works badly with cases when we > > need > > to change field values in super classes. If there is a lot of inheritance > > as > > in my case: > > ParentA, ChildA0, ChildA1.., ParentB, ChildB0, ChildB1..,... then situation > > is > > becoming very bad. Maybe in future there will be other solutions in CDI > > specs. > > > > I found two additional ways that can be used. 1) Inject not beans but > > instances, > > + method SimpleFoo newFoo {return Instance.get} + overriding. > > 2) Inject BeanManager + method SimpleFoo newFoo() {beanManager...} + > > overriding. > > > > Maybe such ways can be named lazy/postponed initialization with overriding > > support.... > > > > Best regards, Alex > > > > > > > > > > ???????, 29 ??????? 2017, 18:22 +03:00 ?? Martin Kouba < mkouba at redhat.com > > >: > > > > Hi Alex, > > > > that's an interesting question. Indeed, qualifiers are the way to go if > > you need to keep the method signature. > > > > Another way could be to override the setFoo() method so that the Child > > initializer is ignored and add a new method to inject AdvancedFoo: > > > > @Override > > protected void setFoo(SimpleFoo foo) { // Do nothing } > > > > @Inject > > void setAdvancedFoo(AdvancedFoo foo) { > > super.setFoo(foo); > > } > > > > However, note that right now there are the following beans: > > > > SimpleFoo with bean types Object, SimpleFoo > > AdvancedFoo -> Object, SimpleFoo, AdvancedFoo > > > > So if you do @Inject SimpleFoo you get ambiguous dependency exception > > because both SimpleFoo and AdvancedFoo are eligible for injection. > > > > To resolve this you need to use qualifiers or restrict the bean types of > > AdvancedFoo: > > > > @Typed(AdvancedFoo.class) > > class AdvancedFoo extends SimpleFoo {} > > > > HTH > > > > Martin > > > > > > Dne 29.8.2017 v 15:09 Matej Novotny napsal(a): > > > Hi Alex, > > > > > > no need to be sorry, you have come to the right place :) > > > As for your question, the simplest thing is probably to use qualifiers. > > > > > > Create your own like this: > > > > > > @Qualifier > > > @Retention(RetentionPolicy.RUNTIME) > > > @Target({ ElementType.TYPE, ElementType.PARAMETER, ElementType.FIELD, > > > ElementType.METHOD }) > > > public @interface MyQualifier {} > > > > > > > > > And then change your AdvancedFoo class to use the qualifier: > > > > > > @Dependent > > > @MyQualifier > > > public class AdvancedFoo extends SimpleFoo { > > > } > > > > > > And accordingly, the init method which uses injection should then look > > > like > > > this: > > > > > > @Dependent > > > public class Parent extends Child { > > > > > > @Inject > > > @Override > > > protected void setFoo(@MyQualifier SimpleFoo foo) { > > > super.setFoo(foo); > > > } > > > } > > > > > > Does this answer your question? > > > > > > Matej > > > > > > ----- Original Message ----- > > >> From: "Alex Sviridov" < ooo_saturn7 at mail.ru > > > >> To: "weld-dev" < weld-dev at lists.jboss.org > > > >> Sent: Tuesday, August 29, 2017 1:46:23 PM > > >> Subject: [weld-dev] How to make method injection when bean subclass is > > >> required in Weld? > > >> > > >> Hi all, > > >> > > >> I am really sorry for writing to this mailing list, but I checked all > > >> user > > >> forums and chats and saw that they are very old. > > >> > > >> I would be very thankful if someone gives suggestion for solving the > > >> following problem. > > >> I have a child and parent class. Child has SimpleFoo, Parent needs > > >> Advaced > > >> foo. So, > > >> > > >> @Dependent > > >> public class SimpleFoo { > > >> } > > >> > > >> @Dependent > > >> public class AdvancedFoo extends SimpleFoo { > > >> } > > >> > > >> @Dependent > > >> public class Child { > > >> > > >> private SimpleFoo foo; > > >> > > >> @Inject > > >> protected void setFoo(SimpleFoo foo) { > > >> this.foo = foo; > > >> } > > >> } > > >> > > >> @Dependent > > >> public class Parent extends Child { > > >> > > >> @Inject > > >> @Override > > >> protected void setFoo(SimpleFoo foo) { //How to inject here AdvancedFoo? > > >> super.setFoo(foo); > > >> } > > >> } > > >> > > >> How to inject in Parent AdvancedFoo? I know that I can do it via > > >> constructor > > >> injection > > >> but I need method injection. How to do it? Can it be done without using > > >> names > > >> (like MyBean1) > > >> but only using classes (AdvancedFoo)? > > >> > > >> Best regards, Alex > > >> > > >> > > >> > > >> > > >> > > >> -- > > >> Alex Sviridov > > >> > > >> _______________________________________________ > > >> weld-dev mailing list > > >> weld-dev at lists.jboss.org > > >> https://lists.jboss.org/mailman/listinfo/weld-dev > > > _______________________________________________ > > > weld-dev mailing list > > > weld-dev at lists.jboss.org > > > https://lists.jboss.org/mailman/listinfo/weld-dev > > > > > > > -- > > Martin Kouba > > Senior Software Engineer > > Red Hat, Czech Republic > > > > > > _______________________________________________ > > weld-dev mailing list > > weld-dev at lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/weld-dev > > > _______________________________________________ > weld-dev mailing list > weld-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/weld-dev From ooo_saturn7 at mail.ru Wed Aug 30 05:55:11 2017 From: ooo_saturn7 at mail.ru (=?UTF-8?B?QWxleCBTdmlyaWRvdg==?=) Date: Wed, 30 Aug 2017 12:55:11 +0300 Subject: [weld-dev] =?utf-8?q?How_to_make_method_injection_when_bean_subcl?= =?utf-8?q?ass_is_required_in_Weld=3F?= In-Reply-To: <294704991.3480211.1504086307456.JavaMail.zimbra@redhat.com> References: <1504007183.617130319@f465.i.mail.ru> <1504084227.775212976@f378.i.mail.ru> <294704991.3480211.1504086307456.JavaMail.zimbra@redhat.com> Message-ID: <1504086911.845158033@f401.i.mail.ru> Hi Matej Thank you for your comment. However, note, that I wrote foo = newFoo() but not foo = new Foo(); By other words foo is created in newFoo method, but not calling new operator. Best regards, Alex >?????, 30 ??????? 2017, 12:45 +03:00 ?? Matej Novotny : > >Hi Alex > >What you suggest will inevitably fail for the reasons we mentioned previously. >Both approaches will try to resolve a bean of type SimpleFoo which is ambiguous. > >Furthermore, doing `foo = new Foo()` is like saying "goodbye CDI". >If you do this, you control the lifecycle of such object, not CDI. >Therefore, there will be no injection done into such object, neither will CDI be able to dispose of such object. > >Matej > >----- Original Message ----- >> From: "Alex Sviridov" < ooo_saturn7 at mail.ru > >> To: "weld-dev" < weld-dev at lists.jboss.org > >> Sent: Wednesday, August 30, 2017 11:10:27 AM >> Subject: Re: [weld-dev] How to make method injection when bean subclass is required in Weld? >> >> >> >> Hi Matej, >> >> I meant the following (in previous example I had a mistake - called Parent >> Child and Child Parent) >> , now without this mistake: >> 1) >> public class Parent { >> >> @Inject >> private Instance fooInstance; >> >> private SimpleFoo foo; >> >> protected SimpleFoo newFoo() { >> return fooInstance.get(); >> } >> >> @PostConstruct >> private void doPostConstruct() { >> foo = newFoo(); >> } >> } >> >> public class Child extends Parent { >> >> @Inject >> private Instance fooInstance; >> >> @Override >> protected AdvancedFoo newFoo() { >> return fooInstance.get(); >> } >> } >> >> >> 2) >> >> public class Parent { >> >> @Inject >> protected BeanManager beanManager; >> >> private SimpleFoo foo; >> >> protected SimpleFoo newFoo() { >> SimpleFoo foo = constructing bean with BM; >> return foo; >> } >> >> @PostConstruct >> private void doPostConstruct() { >> foo = newFoo(); >> } >> } >> >> public class Child extends Parent { >> >> @Override >> protected AdvancedFoo newFoo() { >> AdvancedFoo foo = constructing bean with BM; >> return foo; >> } >> } >> >> Thank you for your explanation of Typed. I got it. >> >> Best regards, Alex >> >> >> ?????, 30 ??????? 2017, 10:51 +03:00 ?? Matej Novotny < manovotn at redhat.com >: >> >> 1) If you inject Instance, you still have the ambiguous dependency issue >> for any class which does have a subclass. >> E.g. from your sample: >> >> @Inject >> Instance instance; >> >> //within some method >> instance.get(); -> this will blow up because you have two beans which have >> SimpleFoo type (SimpleFoo and AdvancedFoo) >> >> 2) I don't understand what you mean by this. How does BM help here? >> >> >> Sidenote: >> You might want to try and use what Martin said - limiting the types of a bean >> with @Typed(MyClass.Foo). >> That way you have control over the bean types and can further manupulate the >> injection. >> Limit all your children to only the actual subclass type they have: >> >> @Dependent >> @Typed(AdvancedFoo.class) >> public class AdvancedFoo extends SimpleFoo { >> // this ben now only has a bean of AdvancedFoo, e.g. it does not fit into >> injection point for SimpleFoo >> } >> >> And then override the initializer methods like this: >> >> @Dependent >> public class Parent extends Child { >> >> @Inject >> @Override >> protected void setFoo(AdvancedFoo foo) { >> this.foo = foo; // assuming foo is a protected field >> } >> } >> >> Matej >> >> >> ----- Original Message ----- >> > From: "Alex Sviridov" < ooo_saturn7 at mail.ru > >> > To: "weld-dev" < weld-dev at lists.jboss.org > >> > Sent: Tuesday, August 29, 2017 8:54:47 PM >> > Subject: Re: [weld-dev] How to make method injection when bean subclass is >> > required in Weld? >> > >> > I thought here, and would like to share my ideas hoping to get comments >> > from >> > more experienced people. >> > >> > First of all I came to conclusion that CDI works badly with cases when we >> > need >> > to change field values in super classes. If there is a lot of inheritance >> > as >> > in my case: >> > ParentA, ChildA0, ChildA1.., ParentB, ChildB0, ChildB1..,... then situation >> > is >> > becoming very bad. Maybe in future there will be other solutions in CDI >> > specs. >> > >> > I found two additional ways that can be used. 1) Inject not beans but >> > instances, >> > + method SimpleFoo newFoo {return Instance.get} + overriding. >> > 2) Inject BeanManager + method SimpleFoo newFoo() {beanManager...} + >> > overriding. >> > >> > Maybe such ways can be named lazy/postponed initialization with overriding >> > support.... >> > >> > Best regards, Alex >> > >> > >> > >> > >> > ???????, 29 ??????? 2017, 18:22 +03:00 ?? Martin Kouba < mkouba at redhat.com >> > >: >> > >> > Hi Alex, >> > >> > that's an interesting question. Indeed, qualifiers are the way to go if >> > you need to keep the method signature. >> > >> > Another way could be to override the setFoo() method so that the Child >> > initializer is ignored and add a new method to inject AdvancedFoo: >> > >> > @Override >> > protected void setFoo(SimpleFoo foo) { // Do nothing } >> > >> > @Inject >> > void setAdvancedFoo(AdvancedFoo foo) { >> > super.setFoo(foo); >> > } >> > >> > However, note that right now there are the following beans: >> > >> > SimpleFoo with bean types Object, SimpleFoo >> > AdvancedFoo -> Object, SimpleFoo, AdvancedFoo >> > >> > So if you do @Inject SimpleFoo you get ambiguous dependency exception >> > because both SimpleFoo and AdvancedFoo are eligible for injection. >> > >> > To resolve this you need to use qualifiers or restrict the bean types of >> > AdvancedFoo: >> > >> > @Typed(AdvancedFoo.class) >> > class AdvancedFoo extends SimpleFoo {} >> > >> > HTH >> > >> > Martin >> > >> > >> > Dne 29.8.2017 v 15:09 Matej Novotny napsal(a): >> > > Hi Alex, >> > > >> > > no need to be sorry, you have come to the right place :) >> > > As for your question, the simplest thing is probably to use qualifiers. >> > > >> > > Create your own like this: >> > > >> > > @Qualifier >> > > @Retention(RetentionPolicy.RUNTIME) >> > > @Target({ ElementType.TYPE, ElementType.PARAMETER, ElementType.FIELD, >> > > ElementType.METHOD }) >> > > public @interface MyQualifier {} >> > > >> > > >> > > And then change your AdvancedFoo class to use the qualifier: >> > > >> > > @Dependent >> > > @MyQualifier >> > > public class AdvancedFoo extends SimpleFoo { >> > > } >> > > >> > > And accordingly, the init method which uses injection should then look >> > > like >> > > this: >> > > >> > > @Dependent >> > > public class Parent extends Child { >> > > >> > > @Inject >> > > @Override >> > > protected void setFoo(@MyQualifier SimpleFoo foo) { >> > > super.setFoo(foo); >> > > } >> > > } >> > > >> > > Does this answer your question? >> > > >> > > Matej >> > > >> > > ----- Original Message ----- >> > >> From: "Alex Sviridov" < ooo_saturn7 at mail.ru > >> > >> To: "weld-dev" < weld-dev at lists.jboss.org > >> > >> Sent: Tuesday, August 29, 2017 1:46:23 PM >> > >> Subject: [weld-dev] How to make method injection when bean subclass is >> > >> required in Weld? >> > >> >> > >> Hi all, >> > >> >> > >> I am really sorry for writing to this mailing list, but I checked all >> > >> user >> > >> forums and chats and saw that they are very old. >> > >> >> > >> I would be very thankful if someone gives suggestion for solving the >> > >> following problem. >> > >> I have a child and parent class. Child has SimpleFoo, Parent needs >> > >> Advaced >> > >> foo. So, >> > >> >> > >> @Dependent >> > >> public class SimpleFoo { >> > >> } >> > >> >> > >> @Dependent >> > >> public class AdvancedFoo extends SimpleFoo { >> > >> } >> > >> >> > >> @Dependent >> > >> public class Child { >> > >> >> > >> private SimpleFoo foo; >> > >> >> > >> @Inject >> > >> protected void setFoo(SimpleFoo foo) { >> > >> this.foo = foo; >> > >> } >> > >> } >> > >> >> > >> @Dependent >> > >> public class Parent extends Child { >> > >> >> > >> @Inject >> > >> @Override >> > >> protected void setFoo(SimpleFoo foo) { //How to inject here AdvancedFoo? >> > >> super.setFoo(foo); >> > >> } >> > >> } >> > >> >> > >> How to inject in Parent AdvancedFoo? I know that I can do it via >> > >> constructor >> > >> injection >> > >> but I need method injection. How to do it? Can it be done without using >> > >> names >> > >> (like MyBean1) >> > >> but only using classes (AdvancedFoo)? >> > >> >> > >> Best regards, Alex >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> -- >> > >> Alex Sviridov >> > >> >> > >> _______________________________________________ >> > >> weld-dev mailing list >> > >> weld-dev at lists.jboss.org >> > >> https://lists.jboss.org/mailman/listinfo/weld-dev >> > > _______________________________________________ >> > > weld-dev mailing list >> > > weld-dev at lists.jboss.org >> > > https://lists.jboss.org/mailman/listinfo/weld-dev >> > > >> > >> > -- >> > Martin Kouba >> > Senior Software Engineer >> > Red Hat, Czech Republic >> > >> > >> > _______________________________________________ >> > weld-dev mailing list >> > weld-dev at lists.jboss.org >> > https://lists.jboss.org/mailman/listinfo/weld-dev >> >> >> _______________________________________________ >> weld-dev mailing list >> weld-dev at lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/weld-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20170830/6236a098/attachment-0001.html From manovotn at redhat.com Wed Aug 30 07:17:26 2017 From: manovotn at redhat.com (Matej Novotny) Date: Wed, 30 Aug 2017 07:17:26 -0400 (EDT) Subject: [weld-dev] How to make method injection when bean subclass is required in Weld? In-Reply-To: <1504086911.845158033@f401.i.mail.ru> References: <1504007183.617130319@f465.i.mail.ru> <1504084227.775212976@f378.i.mail.ru> <294704991.3480211.1504086307456.JavaMail.zimbra@redhat.com> <1504086911.845158033@f401.i.mail.ru> Message-ID: <1909566097.3510230.1504091846574.JavaMail.zimbra@redhat.com> Hi, yea you are right, I mis-read that. My bad. Anyway, the ambiguous dep. problem still holds true and you have to use another approach. Let us know if @Typed solves your problem or if we should try and find another solution. Matej ----- Original Message ----- > From: "Alex Sviridov" > To: "weld-dev" > Sent: Wednesday, August 30, 2017 11:55:11 AM > Subject: Re: [weld-dev] How to make method injection when bean subclass is required in Weld? > > Hi Matej > > Thank you for your comment. However, note, that I wrote foo = newFoo() but > not foo = new Foo(); > By other words foo is created in newFoo method, but not calling new operator. > > Best regards, Alex > > > > > ?????, 30 ??????? 2017, 12:45 +03:00 ?? Matej Novotny : > > Hi Alex > > What you suggest will inevitably fail for the reasons we mentioned > previously. > Both approaches will try to resolve a bean of type SimpleFoo which is > ambiguous. > > Furthermore, doing `foo = new Foo()` is like saying "goodbye CDI". > If you do this, you control the lifecycle of such object, not CDI. > Therefore, there will be no injection done into such object, neither will CDI > be able to dispose of such object. > > Matej > > ----- Original Message ----- > > From: "Alex Sviridov" < ooo_saturn7 at mail.ru > > > To: "weld-dev" < weld-dev at lists.jboss.org > > > Sent: Wednesday, August 30, 2017 11:10:27 AM > > Subject: Re: [weld-dev] How to make method injection when bean subclass is > > required in Weld? > > > > > > > > Hi Matej, > > > > I meant the following (in previous example I had a mistake - called Parent > > Child and Child Parent) > > , now without this mistake: > > 1) > > public class Parent { > > > > @Inject > > private Instance fooInstance; > > > > private SimpleFoo foo; > > > > protected SimpleFoo newFoo() { > > return fooInstance.get(); > > } > > > > @PostConstruct > > private void doPostConstruct() { > > foo = newFoo(); > > } > > } > > > > public class Child extends Parent { > > > > @Inject > > private Instance fooInstance; > > > > @Override > > protected AdvancedFoo newFoo() { > > return fooInstance.get(); > > } > > } > > > > > > 2) > > > > public class Parent { > > > > @Inject > > protected BeanManager beanManager; > > > > private SimpleFoo foo; > > > > protected SimpleFoo newFoo() { > > SimpleFoo foo = constructing bean with BM; > > return foo; > > } > > > > @PostConstruct > > private void doPostConstruct() { > > foo = newFoo(); > > } > > } > > > > public class Child extends Parent { > > > > @Override > > protected AdvancedFoo newFoo() { > > AdvancedFoo foo = constructing bean with BM; > > return foo; > > } > > } > > > > Thank you for your explanation of Typed. I got it. > > > > Best regards, Alex > > > > > > ?????, 30 ??????? 2017, 10:51 +03:00 ?? Matej Novotny < manovotn at redhat.com > > >: > > > > 1) If you inject Instance, you still have the ambiguous dependency issue > > for any class which does have a subclass. > > E.g. from your sample: > > > > @Inject > > Instance instance; > > > > //within some method > > instance.get(); -> this will blow up because you have two beans which have > > SimpleFoo type (SimpleFoo and AdvancedFoo) > > > > 2) I don't understand what you mean by this. How does BM help here? > > > > > > Sidenote: > > You might want to try and use what Martin said - limiting the types of a > > bean > > with @Typed(MyClass.Foo). > > That way you have control over the bean types and can further manupulate > > the > > injection. > > Limit all your children to only the actual subclass type they have: > > > > @Dependent > > @Typed(AdvancedFoo.class) > > public class AdvancedFoo extends SimpleFoo { > > // this ben now only has a bean of AdvancedFoo, e.g. it does not fit into > > injection point for SimpleFoo > > } > > > > And then override the initializer methods like this: > > > > @Dependent > > public class Parent extends Child { > > > > @Inject > > @Override > > protected void setFoo(AdvancedFoo foo) { > > this.foo = foo; // assuming foo is a protected field > > } > > } > > > > Matej > > > > > > ----- Original Message ----- > > > From: "Alex Sviridov" < ooo_saturn7 at mail.ru > > > > To: "weld-dev" < weld-dev at lists.jboss.org > > > > Sent: Tuesday, August 29, 2017 8:54:47 PM > > > Subject: Re: [weld-dev] How to make method injection when bean subclass > > > is > > > required in Weld? > > > > > > I thought here, and would like to share my ideas hoping to get comments > > > from > > > more experienced people. > > > > > > First of all I came to conclusion that CDI works badly with cases when we > > > need > > > to change field values in super classes. If there is a lot of inheritance > > > as > > > in my case: > > > ParentA, ChildA0, ChildA1.., ParentB, ChildB0, ChildB1..,... then > > > situation > > > is > > > becoming very bad. Maybe in future there will be other solutions in CDI > > > specs. > > > > > > I found two additional ways that can be used. 1) Inject not beans but > > > instances, > > > + method SimpleFoo newFoo {return Instance.get} + overriding. > > > 2) Inject BeanManager + method SimpleFoo newFoo() {beanManager...} + > > > overriding. > > > > > > Maybe such ways can be named lazy/postponed initialization with > > > overriding > > > support.... > > > > > > Best regards, Alex > > > > > > > > > > > > > > > ???????, 29 ??????? 2017, 18:22 +03:00 ?? Martin Kouba < > > > mkouba at redhat.com > > > >: > > > > > > Hi Alex, > > > > > > that's an interesting question. Indeed, qualifiers are the way to go if > > > you need to keep the method signature. > > > > > > Another way could be to override the setFoo() method so that the Child > > > initializer is ignored and add a new method to inject AdvancedFoo: > > > > > > @Override > > > protected void setFoo(SimpleFoo foo) { // Do nothing } > > > > > > @Inject > > > void setAdvancedFoo(AdvancedFoo foo) { > > > super.setFoo(foo); > > > } > > > > > > However, note that right now there are the following beans: > > > > > > SimpleFoo with bean types Object, SimpleFoo > > > AdvancedFoo -> Object, SimpleFoo, AdvancedFoo > > > > > > So if you do @Inject SimpleFoo you get ambiguous dependency exception > > > because both SimpleFoo and AdvancedFoo are eligible for injection. > > > > > > To resolve this you need to use qualifiers or restrict the bean types of > > > AdvancedFoo: > > > > > > @Typed(AdvancedFoo.class) > > > class AdvancedFoo extends SimpleFoo {} > > > > > > HTH > > > > > > Martin > > > > > > > > > Dne 29.8.2017 v 15:09 Matej Novotny napsal(a): > > > > Hi Alex, > > > > > > > > no need to be sorry, you have come to the right place :) > > > > As for your question, the simplest thing is probably to use qualifiers. > > > > > > > > Create your own like this: > > > > > > > > @Qualifier > > > > @Retention(RetentionPolicy.RUNTIME) > > > > @Target({ ElementType.TYPE, ElementType.PARAMETER, ElementType.FIELD, > > > > ElementType.METHOD }) > > > > public @interface MyQualifier {} > > > > > > > > > > > > And then change your AdvancedFoo class to use the qualifier: > > > > > > > > @Dependent > > > > @MyQualifier > > > > public class AdvancedFoo extends SimpleFoo { > > > > } > > > > > > > > And accordingly, the init method which uses injection should then look > > > > like > > > > this: > > > > > > > > @Dependent > > > > public class Parent extends Child { > > > > > > > > @Inject > > > > @Override > > > > protected void setFoo(@MyQualifier SimpleFoo foo) { > > > > super.setFoo(foo); > > > > } > > > > } > > > > > > > > Does this answer your question? > > > > > > > > Matej > > > > > > > > ----- Original Message ----- > > > >> From: "Alex Sviridov" < ooo_saturn7 at mail.ru > > > > >> To: "weld-dev" < weld-dev at lists.jboss.org > > > > >> Sent: Tuesday, August 29, 2017 1:46:23 PM > > > >> Subject: [weld-dev] How to make method injection when bean subclass is > > > >> required in Weld? > > > >> > > > >> Hi all, > > > >> > > > >> I am really sorry for writing to this mailing list, but I checked all > > > >> user > > > >> forums and chats and saw that they are very old. > > > >> > > > >> I would be very thankful if someone gives suggestion for solving the > > > >> following problem. > > > >> I have a child and parent class. Child has SimpleFoo, Parent needs > > > >> Advaced > > > >> foo. So, > > > >> > > > >> @Dependent > > > >> public class SimpleFoo { > > > >> } > > > >> > > > >> @Dependent > > > >> public class AdvancedFoo extends SimpleFoo { > > > >> } > > > >> > > > >> @Dependent > > > >> public class Child { > > > >> > > > >> private SimpleFoo foo; > > > >> > > > >> @Inject > > > >> protected void setFoo(SimpleFoo foo) { > > > >> this.foo = foo; > > > >> } > > > >> } > > > >> > > > >> @Dependent > > > >> public class Parent extends Child { > > > >> > > > >> @Inject > > > >> @Override > > > >> protected void setFoo(SimpleFoo foo) { //How to inject here > > > >> AdvancedFoo? > > > >> super.setFoo(foo); > > > >> } > > > >> } > > > >> > > > >> How to inject in Parent AdvancedFoo? I know that I can do it via > > > >> constructor > > > >> injection > > > >> but I need method injection. How to do it? Can it be done without > > > >> using > > > >> names > > > >> (like MyBean1) > > > >> but only using classes (AdvancedFoo)? > > > >> > > > >> Best regards, Alex > > > >> > > > >> > > > >> > > > >> > > > >> > > > >> -- > > > >> Alex Sviridov > > > >> > > > >> _______________________________________________ > > > >> weld-dev mailing list > > > >> weld-dev at lists.jboss.org > > > >> https://lists.jboss.org/mailman/listinfo/weld-dev > > > > _______________________________________________ > > > > weld-dev mailing list > > > > weld-dev at lists.jboss.org > > > > https://lists.jboss.org/mailman/listinfo/weld-dev > > > > > > > > > > -- > > > Martin Kouba > > > Senior Software Engineer > > > Red Hat, Czech Republic > > > > > > > > > _______________________________________________ > > > weld-dev mailing list > > > weld-dev at lists.jboss.org > > > https://lists.jboss.org/mailman/listinfo/weld-dev > > > > > > _______________________________________________ > > weld-dev mailing list > > weld-dev at lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/weld-dev > > > _______________________________________________ > weld-dev mailing list > weld-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/weld-dev From ooo_saturn7 at mail.ru Thu Aug 31 06:12:02 2017 From: ooo_saturn7 at mail.ru (=?UTF-8?B?QWxleCBTdmlyaWRvdg==?=) Date: Thu, 31 Aug 2017 13:12:02 +0300 Subject: [weld-dev] =?utf-8?q?Fwd=3A_Re=5B2=5D=3A__How_to_make_method_inje?= =?utf-8?q?ction_when_bean_subclass_is_required_in_Weld=3F?= In-Reply-To: References: <1504170452.423847381@f451.i.mail.ru> Message-ID: <1504174322.864817174@f355.i.mail.ru> Hi Martin Thank you very much for your comment and suggestion about improving. Best regards, Alex >???????, 31 ??????? 2017, 12:50 +03:00 ?? Martin Kouba : > >Hi Alex, > >1) should work but looks a little bit cumbersome. WRT 2) you should >avoid using BeanManager to create a bean instance whenever possible. And >in this particular case, if SimpleFoo is @Dependent it wouldn't be >destroyed correctly (@PreDestroy) when Parent or Child is destroyed. > >The following should also work (no need to have two Instance IPs): > >public class Parent { > >???????@Inject >???????private Instance fooInstance; > >???????private SimpleFoo foo; > >???????protected SimpleFoo newFoo() { >?????????????return fooInstance.get(); >???????} > >???????@PostConstruct >???????private void doPostConstruct() { >???????????foo = newFoo(); >???????} >??} > >??public class Child extends Parent { > >???????@Override >???????protected AdvancedFoo newFoo() { >?????????????return fooInstance.select(AdvancedFoo.class).get(); >???????} >??} > > >Martin > >Dne 31.8.2017 v 11:07 Alex Sviridov napsal(a): >> Hi Martin, >> >> >> Could you comment the following solutions? >> >> 1) >> public class Parent { >> >> @Inject >> private Instance fooInstance; >> >> private SimpleFoo foo; >> >> protected SimpleFoo newFoo() { >> return fooInstance.get(); >> } >> >> @PostConstruct >> private void doPostConstruct() { >> foo = newFoo(); >> } >> } >> >> public class Child extends Parent { >> >> @Inject >> private Instance fooInstance; >> >> @Override >> protected AdvancedFoo newFoo() { >> return fooInstance.get(); >> } >> } >> >> >> 2) >> >> public class Parent { >> >> @Inject >> protected BeanManager beanManager; >> >> private SimpleFoo foo; >> >> protected SimpleFoo newFoo() { >> SimpleFoo foo = constructing bean with BM; >> return foo; >> } >> >> @PostConstruct >> private void doPostConstruct() { >> foo = newFoo(); >> } >> } >> >> public class Child extends Parent { >> >> @Override >> protected AdvancedFoo newFoo() { >> AdvancedFoo foo = constructing bean with BM; >> return foo; >> } >> } >> >> >> Best regards, Alex >> >> ?????, 30 ??????? 2017, 10:51 +03:00 ?? Matej Novotny >> < manovotn at redhat.com >: >> >> 1) If you inject Instance, you still have the ambiguous >> dependency issue for any class which does have a subclass. >> E.g. from your sample: >> >> @Inject >> Instance instance; >> >> //within some method >> instance.get(); -> this will blow up because you have two beans >> which have SimpleFoo type (SimpleFoo and AdvancedFoo) >> >> 2) I don't understand what you mean by this. How does BM help here? >> >> >> Sidenote: >> You might want to try and use what Martin said - limiting the types >> of a bean with @Typed(MyClass.Foo). >> That way you have control over the bean types and can further >> manupulate the injection. >> Limit all your children to only the actual subclass type they have: >> >> @Dependent >> @Typed(AdvancedFoo.class) >> public class AdvancedFoo extends SimpleFoo { >> // this ben now only has a bean of AdvancedFoo, e.g. it does not >> fit into injection point for SimpleFoo >> } >> >> And then override the initializer methods like this: >> >> @Dependent >> public class Parent extends Child { >> >> @Inject >> @Override >> protected void setFoo(AdvancedFoo foo) { >> this.foo = foo; // assuming foo is a protected field >> } >> } >> >> Matej >> >> >> ----- Original Message ----- >> > From: "Alex Sviridov" < ooo_saturn7 at mail.ru >> > >> > To: "weld-dev" < weld-dev at lists.jboss.org >> > >> > Sent: Tuesday, August 29, 2017 8:54:47 PM >> > Subject: Re: [weld-dev] How to make method injection when bean >> subclass is required in Weld? >> > >> > I thought here, and would like to share my ideas hoping to get >> comments from >> > more experienced people. >> > >> > First of all I came to conclusion that CDI works badly with cases >> when we >> > need >> > to change field values in super classes. If there is a lot of >> inheritance as >> > in my case: >> > ParentA, ChildA0, ChildA1.., ParentB, ChildB0, ChildB1..,... then >> situation >> > is >> > becoming very bad. Maybe in future there will be other solutions >> in CDI >> > specs. >> > >> > I found two additional ways that can be used. 1) Inject not beans but >> > instances, >> > + method SimpleFoo newFoo {return Instance.get} + >> overriding. >> > 2) Inject BeanManager + method SimpleFoo newFoo() {beanManager...} + >> > overriding. >> > >> > Maybe such ways can be named lazy/postponed initialization with >> overriding >> > support.... >> > >> > Best regards, Alex >> > >> > >> > >> > >> > ???????, 29 ??????? 2017, 18:22 +03:00 ?? Martin Kouba >> < mkouba at redhat.com >: >> > >> > Hi Alex, >> > >> > that's an interesting question. Indeed, qualifiers are the way to >> go if >> > you need to keep the method signature. >> > >> > Another way could be to override the setFoo() method so that the >> Child >> > initializer is ignored and add a new method to inject AdvancedFoo: >> > >> > @Override >> > protected void setFoo(SimpleFoo foo) { // Do nothing } >> > >> > @Inject >> > void setAdvancedFoo(AdvancedFoo foo) { >> > super.setFoo(foo); >> > } >> > >> > However, note that right now there are the following beans: >> > >> > SimpleFoo with bean types Object, SimpleFoo >> > AdvancedFoo -> Object, SimpleFoo, AdvancedFoo >> > >> > So if you do @Inject SimpleFoo you get ambiguous dependency exception >> > because both SimpleFoo and AdvancedFoo are eligible for injection. >> > >> > To resolve this you need to use qualifiers or restrict the bean >> types of >> > AdvancedFoo: >> > >> > @Typed(AdvancedFoo.class) >> > class AdvancedFoo extends SimpleFoo {} >> > >> > HTH >> > >> > Martin >> > >> > >> > Dne 29.8.2017 v 15:09 Matej Novotny napsal(a): >> > > Hi Alex, >> > > >> > > no need to be sorry, you have come to the right place :) >> > > As for your question, the simplest thing is probably to use >> qualifiers. >> > > >> > > Create your own like this: >> > > >> > > @Qualifier >> > > @Retention(RetentionPolicy.RUNTIME) >> > > @Target({ ElementType.TYPE, ElementType.PARAMETER, >> ElementType.FIELD, >> > > ElementType.METHOD }) >> > > public @interface MyQualifier {} >> > > >> > > >> > > And then change your AdvancedFoo class to use the qualifier: >> > > >> > > @Dependent >> > > @MyQualifier >> > > public class AdvancedFoo extends SimpleFoo { >> > > } >> > > >> > > And accordingly, the init method which uses injection should >> then look like >> > > this: >> > > >> > > @Dependent >> > > public class Parent extends Child { >> > > >> > > @Inject >> > > @Override >> > > protected void setFoo(@MyQualifier SimpleFoo foo) { >> > > super.setFoo(foo); >> > > } >> > > } >> > > >> > > Does this answer your question? >> > > >> > > Matej >> > > >> > > ----- Original Message ----- >> > >> From: "Alex Sviridov" < ooo_saturn7 at mail.ru >> > >> > >> To: "weld-dev" < weld-dev at lists.jboss.org >> > >> > >> Sent: Tuesday, August 29, 2017 1:46:23 PM >> > >> Subject: [weld-dev] How to make method injection when bean >> subclass is >> > >> required in Weld? >> > >> >> > >> Hi all, >> > >> >> > >> I am really sorry for writing to this mailing list, but I >> checked all user >> > >> forums and chats and saw that they are very old. >> > >> >> > >> I would be very thankful if someone gives suggestion for >> solving the >> > >> following problem. >> > >> I have a child and parent class. Child has SimpleFoo, Parent >> needs Advaced >> > >> foo. So, >> > >> >> > >> @Dependent >> > >> public class SimpleFoo { >> > >> } >> > >> >> > >> @Dependent >> > >> public class AdvancedFoo extends SimpleFoo { >> > >> } >> > >> >> > >> @Dependent >> > >> public class Child { >> > >> >> > >> private SimpleFoo foo; >> > >> >> > >> @Inject >> > >> protected void setFoo(SimpleFoo foo) { >> > >> this.foo = foo; >> > >> } >> > >> } >> > >> >> > >> @Dependent >> > >> public class Parent extends Child { >> > >> >> > >> @Inject >> > >> @Override >> > >> protected void setFoo(SimpleFoo foo) { //How to inject here >> AdvancedFoo? >> > >> super.setFoo(foo); >> > >> } >> > >> } >> > >> >> > >> How to inject in Parent AdvancedFoo? I know that I can do it via >> > >> constructor >> > >> injection >> > >> but I need method injection. How to do it? Can it be done >> without using >> > >> names >> > >> (like MyBean1) >> > >> but only using classes (AdvancedFoo)? >> > >> >> > >> Best regards, Alex >> > >> >> > >> >> > >> >> > >> >> > >> >> > >> -- >> > >> Alex Sviridov >> > >> >> > >> _______________________________________________ >> > >> weld-dev mailing list >> > >> weld-dev at lists.jboss.org >> > >> https://lists.jboss.org/mailman/listinfo/weld-dev >> > > _______________________________________________ >> > > weld-dev mailing list >> > > weld-dev at lists.jboss.org >> > > https://lists.jboss.org/mailman/listinfo/weld-dev >> > > >> > >> > -- >> > Martin Kouba >> > Senior Software Engineer >> > Red Hat, Czech Republic >> > >> > >> > _______________________________________________ >> > weld-dev mailing list >> > weld-dev at lists.jboss.org >> > https://lists.jboss.org/mailman/listinfo/weld-dev >> >> >> >> ------------------------------------------------------------------------ >> >> -- >> Alex Sviridov > >-- >Martin Kouba >Senior Software Engineer >Red Hat, Czech Republic -- Alex Sviridov -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20170831/a3211b44/attachment-0001.html