You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by Mark Struberg <st...@yahoo.de> on 2010/03/23 17:52:51 UTC

Why are AbstractContext#componentInstanceMaps all WeakHashMaps?

This may lead to loosing contextual instances if they are not referenced between 2 functions in the same Request, isn't? 

wdyt?

LieGrue,
strub

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com 

Re: Why are AbstractContext#componentInstanceMaps all WeakHashMaps?

Posted by Gurkan Erdogdu <gu...@yahoo.com>.
Actually we can do the better than using WeakHashMap . Using map with WeakReference and using ReferenceQueue. Therefore we can inspect queue to get instance and call its contextual destroy method.




________________________________
From: Gurkan Erdogdu <gu...@yahoo.com>
To: dev@openwebbeans.apache.org
Sent: Wed, March 24, 2010 9:11:32 AM
Subject: Re: Why are AbstractContext#componentInstanceMaps all WeakHashMaps?

If you look at the specification, container is able to destroy dependent instances at any time. Please see chapter 6.4.2

"Finally, the container is permitted to destroy any @Dependent scoped contextual instance at any time if the instance is no
longer referenced by the application (excluding weak, soft and phantom references)."

Thanks;




________________________________
From: Mark Struberg <st...@yahoo.de>
To: dev@openwebbeans.apache.org
Sent: Tue, March 23, 2010 11:02:01 PM
Subject: Re: Why are AbstractContext#componentInstanceMaps all WeakHashMaps?

We really need to be careful with WeakHashMaps!

I now hunted 2 hours for a weird bug which behaved sporadic. The reason was that the the CreationalContextImpl#dependentObjects and a few others are now WeakHashMaps. And if the contextual instance is not used anymore, we will simply loose the ability to cleanly destroy those instances and it's dependent objects!

LieGrue,
strub

--- Gurkan Erdogdu <gu...@yahoo.com> schrieb am Di, 23.3.2010:

> Von: Gurkan Erdogdu <gu...@yahoo.com>
> Betreff: Re: Why are AbstractContext#componentInstanceMaps all WeakHashMaps?
> An: dev@openwebbeans.apache.org
> Datum: Dienstag, 23. März, 2010 19:47 Uhr
> Those contextuals are referenced in
> the BeanManagerImpl via Map. And will be there as longs as
> those are not cleared
> 
> 
> 
> 
> ________________________________
> From: Mark Struberg <st...@yahoo.de>
> To: dev@openwebbeans.apache.org
> Sent: Tue, March 23, 2010 6:52:51 PM
> Subject: Why are AbstractContext#componentInstanceMaps all
> WeakHashMaps?
> 
> This may lead to loosing contextual instances if they are
> not referenced between 2 functions in the same Request,
> isn't? 
> 
> wdyt?
> 
> LieGrue,
> strub
> 
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen
> herausragenden Schutz gegen Massenmails. 
> http://mail.yahoo.com
> 
> 
> 
>      
> ___________________________________________________________________
> Yahoo! Türkiye açıldı!  http://yahoo.com.tr
> İnternet üzerindeki en iyi içeriği Yahoo! Türkiye
> sizlere sunuyor!

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com



      ___________________________________________________________________
Yahoo! Türkiye açıldı!  http://yahoo.com.tr
İnternet üzerindeki en iyi içeriği Yahoo! Türkiye sizlere sunuyor!


      ___________________________________________________________________
Yahoo! Türkiye açıldı!  http://yahoo.com.tr
İnternet üzerindeki en iyi içeriği Yahoo! Türkiye sizlere sunuyor!

Re: Why are AbstractContext#componentInstanceMaps all WeakHashMaps?

Posted by Mark Struberg <st...@yahoo.de>.
Yes, the container, and _we_ are the container ;)

Imo this only allows the container (aka us) to destroy the dependent objects later. 

It turned out that the problem was the WeakHashMap in the RequestContext, so I should change probably back CreationalContextImpl#dependentObjects to be a WeakHashMap again.

LieGrue,
strub

--- Gurkan Erdogdu <gu...@yahoo.com> schrieb am Mi, 24.3.2010:

> Von: Gurkan Erdogdu <gu...@yahoo.com>
> Betreff: Re: Why are AbstractContext#componentInstanceMaps all WeakHashMaps?
> An: dev@openwebbeans.apache.org
> Datum: Mittwoch, 24. März, 2010 08:11 Uhr
> If you look at the specification,
> container is able to destroy dependent instances at any
> time. Please see chapter 6.4.2
> 
> "Finally, the container is permitted to destroy any
> @Dependent scoped contextual instance at any time if the
> instance is no
> longer referenced by the application (excluding weak, soft
> and phantom references)."
> 
> Thanks;
> 
> 
> 
> 
> ________________________________
> From: Mark Struberg <st...@yahoo.de>
> To: dev@openwebbeans.apache.org
> Sent: Tue, March 23, 2010 11:02:01 PM
> Subject: Re: Why are AbstractContext#componentInstanceMaps
> all WeakHashMaps?
> 
> We really need to be careful with WeakHashMaps!
> 
> I now hunted 2 hours for a weird bug which behaved
> sporadic. The reason was that the the
> CreationalContextImpl#dependentObjects and a few others are
> now WeakHashMaps. And if the contextual instance is not used
> anymore, we will simply loose the ability to cleanly destroy
> those instances and it's dependent objects!
> 
> LieGrue,
> strub
> 
> --- Gurkan Erdogdu <gu...@yahoo.com>
> schrieb am Di, 23.3.2010:
> 
> > Von: Gurkan Erdogdu <gu...@yahoo.com>
> > Betreff: Re: Why are
> AbstractContext#componentInstanceMaps all WeakHashMaps?
> > An: dev@openwebbeans.apache.org
> > Datum: Dienstag, 23. März, 2010 19:47 Uhr
> > Those contextuals are referenced in
> > the BeanManagerImpl via Map. And will be there as
> longs as
> > those are not cleared
> > 
> > 
> > 
> > 
> > ________________________________
> > From: Mark Struberg <st...@yahoo.de>
> > To: dev@openwebbeans.apache.org
> > Sent: Tue, March 23, 2010 6:52:51 PM
> > Subject: Why are AbstractContext#componentInstanceMaps
> all
> > WeakHashMaps?
> > 
> > This may lead to loosing contextual instances if they
> are
> > not referenced between 2 functions in the same
> Request,
> > isn't? 
> > 
> > wdyt?
> > 
> > LieGrue,
> > strub
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Sie sind Spam leid? Yahoo! Mail verfügt über einen
> > herausragenden Schutz gegen Massenmails. 
> > http://mail.yahoo.com
> > 
> > 
> > 
> >      
> >
> ___________________________________________________________________
> > Yahoo! Türkiye açıldı!  http://yahoo.com.tr
> > İnternet üzerindeki en iyi içeriği Yahoo!
> Türkiye
> > sizlere sunuyor!
> 
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen
> herausragenden Schutz gegen Massenmails. 
> http://mail.yahoo.com
> 
> 
> 
>      
> ___________________________________________________________________
> Yahoo! Türkiye açıldı!  http://yahoo.com.tr
> İnternet üzerindeki en iyi içeriği Yahoo! Türkiye
> sizlere sunuyor!

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com 

Re: Why are AbstractContext#componentInstanceMaps all WeakHashMaps?

Posted by Gurkan Erdogdu <gu...@yahoo.com>.
If you look at the specification, container is able to destroy dependent instances at any time. Please see chapter 6.4.2

"Finally, the container is permitted to destroy any @Dependent scoped contextual instance at any time if the instance is no
longer referenced by the application (excluding weak, soft and phantom references)."

Thanks;




________________________________
From: Mark Struberg <st...@yahoo.de>
To: dev@openwebbeans.apache.org
Sent: Tue, March 23, 2010 11:02:01 PM
Subject: Re: Why are AbstractContext#componentInstanceMaps all WeakHashMaps?

We really need to be careful with WeakHashMaps!

I now hunted 2 hours for a weird bug which behaved sporadic. The reason was that the the CreationalContextImpl#dependentObjects and a few others are now WeakHashMaps. And if the contextual instance is not used anymore, we will simply loose the ability to cleanly destroy those instances and it's dependent objects!

LieGrue,
strub

--- Gurkan Erdogdu <gu...@yahoo.com> schrieb am Di, 23.3.2010:

> Von: Gurkan Erdogdu <gu...@yahoo.com>
> Betreff: Re: Why are AbstractContext#componentInstanceMaps all WeakHashMaps?
> An: dev@openwebbeans.apache.org
> Datum: Dienstag, 23. März, 2010 19:47 Uhr
> Those contextuals are referenced in
> the BeanManagerImpl via Map. And will be there as longs as
> those are not cleared
> 
> 
> 
> 
> ________________________________
> From: Mark Struberg <st...@yahoo.de>
> To: dev@openwebbeans.apache.org
> Sent: Tue, March 23, 2010 6:52:51 PM
> Subject: Why are AbstractContext#componentInstanceMaps all
> WeakHashMaps?
> 
> This may lead to loosing contextual instances if they are
> not referenced between 2 functions in the same Request,
> isn't? 
> 
> wdyt?
> 
> LieGrue,
> strub
> 
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen
> herausragenden Schutz gegen Massenmails. 
> http://mail.yahoo.com
> 
> 
> 
>      
> ___________________________________________________________________
> Yahoo! Türkiye açıldı!  http://yahoo.com.tr
> İnternet üzerindeki en iyi içeriği Yahoo! Türkiye
> sizlere sunuyor!

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com



      ___________________________________________________________________
Yahoo! Türkiye açıldı!  http://yahoo.com.tr
İnternet üzerindeki en iyi içeriği Yahoo! Türkiye sizlere sunuyor!

Re: Why are AbstractContext#componentInstanceMaps all WeakHashMaps?

Posted by Mark Struberg <st...@yahoo.de>.
We really need to be careful with WeakHashMaps!

I now hunted 2 hours for a weird bug which behaved sporadic. The reason was that the the CreationalContextImpl#dependentObjects and a few others are now WeakHashMaps. And if the contextual instance is not used anymore, we will simply loose the ability to cleanly destroy those instances and it's dependent objects!

LieGrue,
strub

--- Gurkan Erdogdu <gu...@yahoo.com> schrieb am Di, 23.3.2010:

> Von: Gurkan Erdogdu <gu...@yahoo.com>
> Betreff: Re: Why are AbstractContext#componentInstanceMaps all WeakHashMaps?
> An: dev@openwebbeans.apache.org
> Datum: Dienstag, 23. März, 2010 19:47 Uhr
> Those contextuals are referenced in
> the BeanManagerImpl via Map. And will be there as longs as
> those are not cleared
> 
> 
> 
> 
> ________________________________
> From: Mark Struberg <st...@yahoo.de>
> To: dev@openwebbeans.apache.org
> Sent: Tue, March 23, 2010 6:52:51 PM
> Subject: Why are AbstractContext#componentInstanceMaps all
> WeakHashMaps?
> 
> This may lead to loosing contextual instances if they are
> not referenced between 2 functions in the same Request,
> isn't? 
> 
> wdyt?
> 
> LieGrue,
> strub
> 
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen
> herausragenden Schutz gegen Massenmails. 
> http://mail.yahoo.com
> 
> 
> 
>      
> ___________________________________________________________________
> Yahoo! Türkiye açıldı!  http://yahoo.com.tr
> İnternet üzerindeki en iyi içeriği Yahoo! Türkiye
> sizlere sunuyor!

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com 

Re: Why are AbstractContext#componentInstanceMaps all WeakHashMaps?

Posted by Gurkan Erdogdu <gu...@yahoo.com>.
Those contextuals are referenced in the BeanManagerImpl via Map. And will be there as longs as those are not cleared




________________________________
From: Mark Struberg <st...@yahoo.de>
To: dev@openwebbeans.apache.org
Sent: Tue, March 23, 2010 6:52:51 PM
Subject: Why are AbstractContext#componentInstanceMaps all WeakHashMaps?

This may lead to loosing contextual instances if they are not referenced between 2 functions in the same Request, isn't? 

wdyt?

LieGrue,
strub

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com



      ___________________________________________________________________
Yahoo! Türkiye açıldı!  http://yahoo.com.tr
İnternet üzerindeki en iyi içeriği Yahoo! Türkiye sizlere sunuyor!