pnoltes commented on PR #428:
URL: https://github.com/apache/celix/pull/428#issuecomment-1179550129

   Interesting and good point to discuss. 
   
   The reason why components are removed by the framework after the bundle 
activator stop is called, is because removing components was originally not 
done by the framework. And retrofitting this behavior before the bundle 
activator stop call, gave problems to existing code. 
   
   Note that this is not the best reason why we have the current logic, but I 
mention this just to explain how this evolved. 
   
   But this is a good discussion, because we also have a different approach for 
components than for service registration, service trackers,etc. 
   
   In the case of components, the framework will automatically do the cleanup 
for a bundle and in the latest changes in master this can even mean that you do 
not need a bundle activator stop function (see 
https://github.com/apache/celix/blob/master/examples/celix-examples/readme_c_examples/src/simple_component_activator.c#L92)
   
   But for service registrations, service trackers and bundle trackers the 
framework will do no such thing and instead will log errors that there are 
missing unregister / stop tracker calls. 
   
   I am not sure if we really need to change the logic when components are 
automatically removed, but instead maybe -  just an idea - focus on also 
automatically unregister services and stop trackers and  promote that user not 
need to write their own bundle activator stop anymore. 
   To support this the register service and track services/bundles calls need 
to be updated to support configuration a unregistered/stopped callback during 
creation.
   This also should make it possible to automatically use async calls stop 
unregister services and stop trackers. 
   
   Lastly by automatically removing components after - and not before - bundle 
activator stop is called, the user has more control over how and when 
components are removed and can for example program the stop order of the 
components. Not a very good reason, because ideally this should not matter. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to