avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Shaw <r...@silveregg.co.jp>
Subject Avoiding disposal of unreleased components at system shutdown
Date Tue, 12 Feb 2002 03:47:55 GMT

I have a question about the disposal of unreleased components 
at system shutdown.

Currently, it seems that when the ExcaliburComponentManager is 
disposed, it loops through all of its ComponentHandlers and calls 
dispose on each of them. The dispose implementation in 
ThreadSafeComponentHandler then simply stops and disposes the 
ThreadSafeComponent it is handling.

This seems flawed to me. Consider the following situation: 

MyComponent uses DataSourceComponent. Specifically, it obtains 
a reference to DataSourceComponent when it is initialized, and 
then when it is disposed uses it to write some state information
to a database and releases it.

DataSourceComponent is ThreadSafe, so ExcaliburComponentManager uses 
ThreadSafeComponentHandler to manage a single instance of it.

The system is shut down, which disposes the ExcaliburComponentManager.
It loops through its ComponentHandlers in no guaranteed order, so
maybe DataSourceComponent is disposed before MyComponent, ** even 
though MyComponent has not yet released DataSourceComponent **.

Thus MyComponent cannot be disposed of correctly.

If my analysis is correct, ThreadSafeComponentHandler needs to keep
reference counts, and ExcaliburComponentManager needs to check that
handlers are disposable before actually disposing them. Or maybe
the m_componentMapping could be checked at dispose() to ensure that
only released components are disposed, and a warning could be logged 
if all released components have been disposed and there are still
unreleased components? (At that point ECM could "force" disposal of
the unreleased components.) In the example above, this would force users
to release MyComponent at system shutdown before disposing of
the ExcaliburComponentManager to avoid warnings.

What do you think?



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