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 <[email protected]> To: [email protected] 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 <[email protected]> To: [email protected] 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 <[email protected]> schrieb am Di, 23.3.2010: > Von: Gurkan Erdogdu <[email protected]> > Betreff: Re: Why are AbstractContext#componentInstanceMaps all WeakHashMaps? > An: [email protected] > 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 <[email protected]> > To: [email protected] > 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!
