avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leo Sutic" <leo.su...@inspireinfrastructure.com>
Subject RE: When use ServiceManager.release(obj)?
Date Mon, 15 Dec 2003 19:15:02 GMT
Use the finalize() method of the proxy.

Alternatively, do this in the component manager:

   HashMap objectsOutput = new HashMap ();

   public Object lookup (String role) {
       Object component = ... however you look it up ...

       Exception snapshot = new Exception ();
       objectsOutput.put (component, snapshot);

       return component;
   }

   public void release (Object o) {
       objectsOutput.remove (o);

       ... normal release ...
   }

   public void dispose () {
       // Print out anything in objectsOutput - 
       // those are the components that were looked up
       // but never released.
   }

ThreadSafe components are trickier, as you keep returning 
different instances, but also not as ciritcal to test.

Then again, if you always wrap the component you return
from lookup() in a proxy, then you use a new proxy every
time, and the above should work.

/LS

> From: Niclas Hedhman [mailto:niclas@hedhman.org] 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Mime
View raw message