Another useful link: http://www.artima.com/designtechniques/cleanupP.html
The author does not recommend using a design that relies on timely invocation of finalizers. It seems PhantomReferences are not better, since an object becomes phantom reachable after finalization, so phantom reference is equivalent to a finalizer and you don't know when either will happen.
Another possible alternative is to use 2 references for each EnterpriseContext a SoftReference and a Phantom reference. In such a case, if you correlate the soft reference at the time it is placed onto the reference queue to the phantom reference, you'll still be able to access the ctx object. But you are not guaranteed that the finalizer has not been called yet (in case default finalizer does nothing, it's ok), but a safer alternative is to check & perform passivation in finalize() and do a similar check & passivate if needed when SoftReference is enqueued, whichever one ends up being first succeeds, if you synchronize properly.
Is this too convoluted?
-- Anatoly
------------------------------------------------------- This SF.net email is sponsored by: VM Ware With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 _______________________________________________ JBoss-Development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
