Hi,

diving through the source I think I have found the location where we can fix 
this all: it is the InjectionResolver#implResolveByType
That is the latest location that has the complete type-info. At this point, if 
the resolution process resolves to the (only) InstanceBean or the (only) 
EventBean, we should replace that InstanceBean or EventBean with an 
InstanceBean or EventBean that contains the generic type information. I think, 
this would work and would make the ThreadLocals obsolete, wdyt?

I have not thought about the InjectionPointBean, but this would probably the 
right place to handle that, too.

Cheers,
Arne

--
 
Arne Limburg - Enterprise Architekt
open knowledge GmbH, Oldenburg
Bismarckstraße 13, 26122 Oldenburg
Mobil: +49 (0) 151 108 22 942
Tel: +49 (0) 441 - 4082-0
Fax: +49 (0) 441 - 4082-111
[email protected]
http://www.openknowledge.de

Registergericht: Amtsgericht Oldenburg, HRB 4670
Geschäftsführer: Lars Röwekamp, Jens Schumann


-----Ursprüngliche Nachricht-----
Von: Mark Struberg [mailto:[email protected]] 
Gesendet: Sonntag, 25. September 2011 14:04
An: [email protected]
Betreff: Re: AW: Yan: proper Handling of InjectionPoints

I think the problem here is that we do fail in correctly handling parameterized 
types in a generic way.

Having the InjectionPoint is only really important for @Dependent beans. When 
you resolve them manually via BeanManager#getReference, then you don't have an 
InjectionPoint at all!

If you look at all the 3 'special' beans, then the only info taken from the 
injection point is about the Paremeterized types info.

But you will get the same problems if you use 


BeanManager#getBeans( new TypeLiteral<MyBean<UserDbt>>(){}.getType() );


The info about the parameterized type simply will get lost ...

Btw, not sure if this works in Weld - but I think it should ;)


LieGrue,
strub


----- Original Message -----
> From: Arne Limburg <[email protected]>
> To: "[email protected]" <[email protected]>
> Cc: 
> Sent: Saturday, September 24, 2011 8:22 PM
> Subject: AW: Yan: proper Handling of InjectionPoints
> 
> Hi,
> 
> I think the conceptual problem here is, that OWB has exactly one 
> InstanceBean and one EventBean. In fact we should have one InstanceBean per 
> InjectionPoint.
> This bean would have enough information to remove the ThreadLocal. But 
> I don't know how much impact such change would have on the code. I'll 
> take a look at that, too. Maybe that could be done with not much changes.
> 
> Btw. OWB-567 is that same problem
> 
> Cheers,
> Arne
> 
> --
> 
> Arne Limburg - Enterprise Architekt
> open knowledge GmbH, Oldenburg
> Bismarckstraße 13, 26122 Oldenburg
> Mobil: +49 (0) 151 108 22 942
> Tel: +49 (0) 441 - 4082-0
> Fax: +49 (0) 441 - 4082-111
> [email protected]
> http://www.openknowledge.de
> 
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> Geschäftsführer: Lars Röwekamp, Jens Schumann
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Mark Struberg [mailto:[email protected]]
> Gesendet: Samstag, 24. September 2011 17:01
> An: openwebbeans-dev
> Betreff: Re: Yan: proper Handling of InjectionPoints
> 
> Hi!
> 
> Yes, I think it was the best solution in the short time we had back 
> then. But now we should aim for a better solution I think.
> 
> Imo we should add the InjectionPoint info to our internal 
> createInstance methods somehow, wdyt?
> 
> 
> LieGrue,
> strub
> 
> 
> 
> 
>> ________________________________
>> From: Gurkan Erdogdu <[email protected]>
>> To: "[email protected]" 
> <[email protected]>; Mark
>> Struberg <[email protected]>
>> Sent: Saturday, September 24, 2011 3:04 PM
>> Subject: Yan: proper Handling of InjectionPoints
>> 
>> 
>> Hello Mark,
>> 
>> 
>> As far as I remembered, these tricks were required to satisfy 
>> circular
> injections and some other complex stuff. I have to look at the code in 
> detailed to provide more satisfying answers!
>> 
>> 
>> 
>> Cheers,
>> 
>> 
>> Gurkan
>> 
>> 
>> 
>> 
>> ________________________________
>> Kimden: Mark Struberg <[email protected]>
>> Kime: openwebbeans-dev <[email protected]> Gönderildiği
>> Tarih: 24 Eylül 2011 13:57 Cumartesi
>> Konu: proper Handling of InjectionPoints
>> 
>> Hi!
>> 
>> Whilst working on OWB-617 I figured that we still have this utterly 
>> ugly
> public ThreadLocals in a few of our Beans (InstanceBean, EventBean, 
> InjectionPointBean).
>> All of them just need the information about the InjectionPoint they 
>> get
> injected to. Cant we just solve this somehow different?
>> 
>> This is really broken because of a few reasons:
>> 
>> 1.) Some of this code just crashes with a NPE if the contextual 
>> instances
> get resolved via BeanManager#getReference manually. Because in this 
> situation there is no InjectionPoint and the code which usually fills 
> the ThreadLocals didn't get called earlier...
>> 
>> 2.) We will crash heavily (or more worse: produce wrong results) if 
>> the creation is nested somehow. Because the ThreadLocal can only 
>> contain 1 entry for each
> thread. but if (while creating one bean) we need to inject another one 
> of that kind, then we are doomed! This situation might happen if we 
> have a few nested @Dependent beans or if we touch a subsequent member 
> in any @Inject or @PostConstruct methods.
>> 
>> Anyone got an idea how to solve this? Gurkan?
>> I have looked through our code and have some gut feeling already, but 
>> I
> might need some feedback from you guys!
>> We can walk through the code together via IRC or hold a quick 
>> voicemail,
> teamspeak or skype meeting if you like.
>> 
>> LieGrue,
>> strub
>> 
>> 
>> 
>> 
>> 
>> 
>

Reply via email to