avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leif Mortenson <l...@silveregg.co.jp>
Subject Re: Avoiding disposal of unreleased components at system shutdown
Date Thu, 14 Feb 2002 01:53:47 GMT

Peter Donald wrote:

>On Wed, 13 Feb 2002 19:57, Leif Mortenson wrote:
>>Wouldn't it also be possible just to keep track of the number of lookups
>>- releases.  Then when you want to dispose the ComponentManager go into
>>a loop.  Call dispose on any components whose count is 0. Disposing them
>>should release other components.  Repeat.  If you reach a point where
>>you don't have any components with a count of 0, then this is an error
>>and a warning should be displayed before going ahead and disposing the
>>rest of them.
>Yep ... but it is a strategy I recall from my C++/COM days which I still 
>shudder at ;) I remember quite a few cases where I had to debug each others 
>code because components where forced to be shutdown and couldn't gracefully 
>go down. Especially when there is circular dependencies that creep in without 
>you noticing ;)
I don't think that you can start things up with circular dependencies. 
 If Component A obtaines a reference to Component B in A's initialize 
method, that will work.  But if B also tries to obtain a reference to 
Component A that will fail because A has not yet been initialized.  (I 
think that it actually creates another copy of Compnent A which in turn 
creates a second copy of B etc... Going into an infinite loop... ??  I 
ran into this creating the datasource.cluster package.)

As long as components are looked up and released in the initialize and 
dispose methods you shouldn't be able to get into any circular 
dependency problems.

>>This way the ComponentManager takes care of the dependencies on its own
>>without requiring the developer to set up their dependencies correctly.
>True it is easier in shortterm and much less complex.
Ryan is writing a patch to fix the problems we are having and will 
submit that so you can try it out before it gets committed.


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

View raw message