You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by Arne Limburg <ar...@openknowledge.de> on 2014/11/22 11:58:42 UTC

Re: [cdi-dev] Getting injection point from Bean#create

Damn, should have made an svn up, before I started ;-)

I reviewed your fix and I am not happy with it. Lookup of the InjectionPoint should be possible from everywhere, where it is available (i.e. In a Constructor of a @Dependent bean) and not only from ThirdPartyBean#create

So, I propose that we never throw the exception but assume that it is a lookup in that case.

Other opinions?

Cheers,
Arne

Von: Romain Manni-Bucau <rm...@gmail.com>>
Datum: Samstag, 22. November 2014 11:40
An: Arne Limburg <ar...@openknowledge.de>>
Betreff: Re: [cdi-dev] Getting injection point from Bean#create


Test is passing ;). Test should be sthg like GetInjectionPoint*Test

Le 22 nov. 2014 11:30, "Arne Limburg" <ar...@openknowledge.de>> a écrit :
Oh, ok, what’s its name?
Are you already working on a fix?

Von: Romain Manni-Bucau <rm...@gmail.com>>
Datum: Samstag, 22. November 2014 11:27
An: Arne Limburg <ar...@openknowledge.de>>
Betreff: Fwd: Re: [cdi-dev] Getting injection point from Bean#create


Hi Arne

I added a test yesterday for it

---------- Message transféré ----------
De : "Arne Limburg" <ar...@openknowledge.de>>
Date : 22 nov. 2014 11:24
Objet : Re: [cdi-dev] Getting injection point from Bean#create
À : "arjan tijms" <ar...@gmail.com>>
Cc : "cdi-dev@lists.jboss.org<ma...@lists.jboss.org>" <cd...@lists.jboss.org>>

Hi Arjan,

I¹ve verified, that this is a bug in OpenWebBeans.
I've created
https://issues.apache.org/jira/browse/OWB-1030
and I¹m going to fix it.

Btw.: You have to use the CreationalContext of the bean (the way OWB
currently throws the "Inconsistent injection point stack" exception)

Cheers,
Arne


Am 21.11.14 12:58 schrieb "arjan tijms" unter <ar...@gmail.com>>:

>Hi,
>
>On Fri, Nov 21, 2014 at 10:31 AM, Jozef Hartinger <jh...@redhat.com>>
>wrote:
>> Here is my understanding of Arjan's
>> setup:
>> [...]
>>
>> This is no different from a producer method injecting InjectionPoint
>> directly.
>
>That's indeed the exact setup.
>
>On Fri, Nov 21, 2014 at 11:34 AM, Romain Manni-Bucau
><rm...@gmail.com>> wrote:
>> PS: BTW should work on OWB 1.5.0-SNAPSHOT now
>
>Wow, I'll look at the latest SNAPSHOT of OWB then. Thanks Romain!
>
>Kind regards,
>Arjan
>
>
>
>
>>
>>
>> On 11/21/2014 10:23 AM, Romain Manni-Bucau wrote:
>>>
>>> yes but what would mean any of the values? Not bound to any injection
>>> it doesn't mean anything
>>>
>>>
>>> Romain Manni-Bucau
>>> @rmannibucau
>>> http://www.tomitribe.com
>>> http://rmannibucau.wordpress.com
>>> https://github.com/rmannibucau
>>>
>>>
>>> 2014-11-21 10:19 GMT+01:00 Jozef Hartinger <jh...@redhat.com>>:
>>>>
>>>> It means "give me an instance of type InjectionPoint and @Default
>>>> qualifier". In default setup this should be served by the built-in
>>>> Bean<InjectionPoint>".
>>>>
>>>>
>>>> On 11/21/2014 10:12 AM, Romain Manni-Bucau wrote:
>>>>>
>>>>> @Jozef: InjectionPoint ip = getBean(InjectionPoint.class); doesn't
>>>>> mean anything in the absolute. So why should it be allowed?
>>>>>
>>>>>
>>>>> Romain Manni-Bucau
>>>>> @rmannibucau
>>>>> http://www.tomitribe.com
>>>>> http://rmannibucau.wordpress.com
>>>>> https://github.com/rmannibucau
>>>>>
>>>>>
>>>>> 2014-11-21 9:57 GMT+01:00 Jozef Hartinger <jh...@redhat.com>>:
>>>>>>
>>>>>> The workaround is very ugly. Instead of going that path OWB should
>>>>>>be
>>>>>> fixed
>>>>>> to support the simple way.
>>>>>>
>>>>>>
>>>>>> On 11/20/2014 11:22 PM, arjan tijms wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> On Thu, Nov 20, 2014 at 11:07 PM, Romain Manni-Bucau
>>>>>>> <rm...@gmail.com>> wrote:
>>>>>>>>
>>>>>>>> Not sure what it means actually. InjectionPoint is highly
>>>>>>>>contextual
>>>>>>>> so
>>>>>>>> having an exception (not a npe of course) would make sense to me.
>>>>>>>>
>>>>>>>> Bean#create is a "you know what you do" from my understanding
>>>>>>>>since
>>>>>>>> interceptors/decorators are not supported for instance so it
>>>>>>>>shouldnt
>>>>>>>> rely
>>>>>>>> of things like that, no?
>>>>>>>
>>>>>>> Sure, no interceptor/decorators, but the injection point -is-
>>>>>>>there of
>>>>>>> course. I can see it being set in OWB as a special property on the
>>>>>>> creational context if I walk down the stack trace in a debugger
>>>>>>>when
>>>>>>> my Bean#create method is being called. An injection point is
>>>>>>>something
>>>>>>> that implementations of Bean could always need, for instance to
>>>>>>> retrieve the name of the field into which injection is taking
>>>>>>>place.
>>>>>>>
>>>>>>> Of course, it being a "you know what you do", it's okay that it's
>>>>>>>not
>>>>>>> as simple as having it injected into the Bean, and that some extra
>>>>>>> code is needed to obtain it. As long as there is at least -a- way
>>>>>>>to
>>>>>>> get hold of it.
>>>>>>>
>>>>>>> The method I posted in the openings post does in fact work, but it
>>>>>>> feels slightly hacky. If that's an acceptable way to get the
>>>>>>>injection
>>>>>>> point, then so be it. But just wondering if it's not something that
>>>>>>> works by chance and may break later.
>>>>>>>
>>>>>>> Kind regards,
>>>>>>> Arjan
>>>>>>> _______________________________________________
>>>>>>> cdi-dev mailing list
>>>>>>> cdi-dev@lists.jboss.org<ma...@lists.jboss.org>
>>>>>>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>>>>>>>
>>>>>>> Note that for all code provided on this list, the provider licenses
>>>>>>> the
>>>>>>> code under the Apache License, Version 2
>>>>>>> (http://www.apache.org/licenses/LICENSE-2.0.html). For all other
>>>>>>>ideas
>>>>>>> provided on this list, the provider waives all patent and other
>>>>>>> intellectual
>>>>>>> property rights inherent in such information.
>>>>>>
>>>>>>
>>
>_______________________________________________
>cdi-dev mailing list
>cdi-dev@lists.jboss.org<ma...@lists.jboss.org>
>https://lists.jboss.org/mailman/listinfo/cdi-dev
>
>Note that for all code provided on this list, the provider licenses the
>code under the Apache License, Version 2
>(http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
>provided on this list, the provider waives all patent and other
>intellectual property rights inherent in such information.


_______________________________________________
cdi-dev mailing list
cdi-dev@lists.jboss.org<ma...@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/cdi-dev

Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.

Re: [cdi-dev] Getting injection point from Bean#create

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Do it if you want but I thought it shouldn't be used and @Inject
InjectionPoint should be the clean solution. That said nothing more
against so feel free to remove this restriction.


Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau


2014-11-22 11:58 GMT+01:00 Arne Limburg <ar...@openknowledge.de>:
> Damn, should have made an svn up, before I started ;-)
>
> I reviewed your fix and I am not happy with it. Lookup of the InjectionPoint
> should be possible from everywhere, where it is available (i.e. In a
> Constructor of a @Dependent bean) and not only from ThirdPartyBean#create
>
> So, I propose that we never throw the exception but assume that it is a
> lookup in that case.
>
> Other opinions?
>
> Cheers,
> Arne
>
> Von: Romain Manni-Bucau <rm...@gmail.com>
> Datum: Samstag, 22. November 2014 11:40
> An: Arne Limburg <ar...@openknowledge.de>
> Betreff: Re: [cdi-dev] Getting injection point from Bean#create
>
> Test is passing ;). Test should be sthg like GetInjectionPoint*Test
>
> Le 22 nov. 2014 11:30, "Arne Limburg" <ar...@openknowledge.de> a
> écrit :
>>
>> Oh, ok, what’s its name?
>> Are you already working on a fix?
>>
>> Von: Romain Manni-Bucau <rm...@gmail.com>
>> Datum: Samstag, 22. November 2014 11:27
>> An: Arne Limburg <ar...@openknowledge.de>
>> Betreff: Fwd: Re: [cdi-dev] Getting injection point from Bean#create
>>
>> Hi Arne
>>
>> I added a test yesterday for it
>>
>> ---------- Message transféré ----------
>> De : "Arne Limburg" <ar...@openknowledge.de>
>> Date : 22 nov. 2014 11:24
>> Objet : Re: [cdi-dev] Getting injection point from Bean#create
>> À : "arjan tijms" <ar...@gmail.com>
>> Cc : "cdi-dev@lists.jboss.org" <cd...@lists.jboss.org>
>>
>> Hi Arjan,
>>
>> I¹ve verified, that this is a bug in OpenWebBeans.
>> I've created
>> https://issues.apache.org/jira/browse/OWB-1030
>> and I¹m going to fix it.
>>
>> Btw.: You have to use the CreationalContext of the bean (the way OWB
>> currently throws the "Inconsistent injection point stack" exception)
>>
>> Cheers,
>> Arne
>>
>>
>> Am 21.11.14 12:58 schrieb "arjan tijms" unter <ar...@gmail.com>:
>>
>> >Hi,
>> >
>> >On Fri, Nov 21, 2014 at 10:31 AM, Jozef Hartinger <jh...@redhat.com>
>> >wrote:
>> >> Here is my understanding of Arjan's
>> >> setup:
>> >> [...]
>> >>
>> >> This is no different from a producer method injecting InjectionPoint
>> >> directly.
>> >
>> >That's indeed the exact setup.
>> >
>> >On Fri, Nov 21, 2014 at 11:34 AM, Romain Manni-Bucau
>> ><rm...@gmail.com> wrote:
>> >> PS: BTW should work on OWB 1.5.0-SNAPSHOT now
>> >
>> >Wow, I'll look at the latest SNAPSHOT of OWB then. Thanks Romain!
>> >
>> >Kind regards,
>> >Arjan
>> >
>> >
>> >
>> >
>> >>
>> >>
>> >> On 11/21/2014 10:23 AM, Romain Manni-Bucau wrote:
>> >>>
>> >>> yes but what would mean any of the values? Not bound to any injection
>> >>> it doesn't mean anything
>> >>>
>> >>>
>> >>> Romain Manni-Bucau
>> >>> @rmannibucau
>> >>> http://www.tomitribe.com
>> >>> http://rmannibucau.wordpress.com
>> >>> https://github.com/rmannibucau
>> >>>
>> >>>
>> >>> 2014-11-21 10:19 GMT+01:00 Jozef Hartinger <jh...@redhat.com>:
>> >>>>
>> >>>> It means "give me an instance of type InjectionPoint and @Default
>> >>>> qualifier". In default setup this should be served by the built-in
>> >>>> Bean<InjectionPoint>".
>> >>>>
>> >>>>
>> >>>> On 11/21/2014 10:12 AM, Romain Manni-Bucau wrote:
>> >>>>>
>> >>>>> @Jozef: InjectionPoint ip = getBean(InjectionPoint.class); doesn't
>> >>>>> mean anything in the absolute. So why should it be allowed?
>> >>>>>
>> >>>>>
>> >>>>> Romain Manni-Bucau
>> >>>>> @rmannibucau
>> >>>>> http://www.tomitribe.com
>> >>>>> http://rmannibucau.wordpress.com
>> >>>>> https://github.com/rmannibucau
>> >>>>>
>> >>>>>
>> >>>>> 2014-11-21 9:57 GMT+01:00 Jozef Hartinger <jh...@redhat.com>:
>> >>>>>>
>> >>>>>> The workaround is very ugly. Instead of going that path OWB should
>> >>>>>>be
>> >>>>>> fixed
>> >>>>>> to support the simple way.
>> >>>>>>
>> >>>>>>
>> >>>>>> On 11/20/2014 11:22 PM, arjan tijms wrote:
>> >>>>>>>
>> >>>>>>> Hi,
>> >>>>>>>
>> >>>>>>> On Thu, Nov 20, 2014 at 11:07 PM, Romain Manni-Bucau
>> >>>>>>> <rm...@gmail.com> wrote:
>> >>>>>>>>
>> >>>>>>>> Not sure what it means actually. InjectionPoint is highly
>> >>>>>>>>contextual
>> >>>>>>>> so
>> >>>>>>>> having an exception (not a npe of course) would make sense to me.
>> >>>>>>>>
>> >>>>>>>> Bean#create is a "you know what you do" from my understanding
>> >>>>>>>>since
>> >>>>>>>> interceptors/decorators are not supported for instance so it
>> >>>>>>>>shouldnt
>> >>>>>>>> rely
>> >>>>>>>> of things like that, no?
>> >>>>>>>
>> >>>>>>> Sure, no interceptor/decorators, but the injection point -is-
>> >>>>>>>there of
>> >>>>>>> course. I can see it being set in OWB as a special property on the
>> >>>>>>> creational context if I walk down the stack trace in a debugger
>> >>>>>>>when
>> >>>>>>> my Bean#create method is being called. An injection point is
>> >>>>>>>something
>> >>>>>>> that implementations of Bean could always need, for instance to
>> >>>>>>> retrieve the name of the field into which injection is taking
>> >>>>>>>place.
>> >>>>>>>
>> >>>>>>> Of course, it being a "you know what you do", it's okay that it's
>> >>>>>>>not
>> >>>>>>> as simple as having it injected into the Bean, and that some extra
>> >>>>>>> code is needed to obtain it. As long as there is at least -a- way
>> >>>>>>>to
>> >>>>>>> get hold of it.
>> >>>>>>>
>> >>>>>>> The method I posted in the openings post does in fact work, but it
>> >>>>>>> feels slightly hacky. If that's an acceptable way to get the
>> >>>>>>>injection
>> >>>>>>> point, then so be it. But just wondering if it's not something
>> >>>>>>> that
>> >>>>>>> works by chance and may break later.
>> >>>>>>>
>> >>>>>>> Kind regards,
>> >>>>>>> Arjan
>> >>>>>>> _______________________________________________
>> >>>>>>> cdi-dev mailing list
>> >>>>>>> cdi-dev@lists.jboss.org
>> >>>>>>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>> >>>>>>>
>> >>>>>>> Note that for all code provided on this list, the provider
>> >>>>>>> licenses
>> >>>>>>> the
>> >>>>>>> code under the Apache License, Version 2
>> >>>>>>> (http://www.apache.org/licenses/LICENSE-2.0.html). For all other
>> >>>>>>>ideas
>> >>>>>>> provided on this list, the provider waives all patent and other
>> >>>>>>> intellectual
>> >>>>>>> property rights inherent in such information.
>> >>>>>>
>> >>>>>>
>> >>
>> >_______________________________________________
>> >cdi-dev mailing list
>> >cdi-dev@lists.jboss.org
>> >https://lists.jboss.org/mailman/listinfo/cdi-dev
>> >
>> >Note that for all code provided on this list, the provider licenses the
>> >code under the Apache License, Version 2
>> >(http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
>> >provided on this list, the provider waives all patent and other
>> >intellectual property rights inherent in such information.
>>
>>
>> _______________________________________________
>> cdi-dev mailing list
>> cdi-dev@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>>
>> Note that for all code provided on this list, the provider licenses the
>> code under the Apache License, Version 2
>> (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
>> provided on this list, the provider waives all patent and other intellectual
>> property rights inherent in such information.