Community
Participate
Working Groups
I20100121 We still rely on the start() and stop() methods in various p2 bundles to do initialization and cleanup. Most of this work should be moved into agent lifecycle methods instead, since the lifecycle of a p2 agent does not necessarily match the lifecycle of the bundles providing the agent services (although it happens to be true in the SDK case for the agent of the currently running system).
Thomas, this is related to the work you are interested in to finally get rid service registrations for p2 services, so CCing you to keep you in the loop.
Created attachment 156884 [details] Initial work Here is some initial work I did on this while exploring bug 300259. It does the following: - Adds an IAgentService interface with service lifecycle methods (start, stop). Services can optionally implement this interface if they have lifecycle operations (init, cleanup), they need to perform. The methods are called when a service is added to or removed from the agent, or when the agent itself is stopped. - Made ProvisioningEventBus implement IAgentService, to cleanup an event bus leak that we currently have in M5. Essentially each time you create an event bus (e.g., invoke the director application), it leaks one event bus. This is fixed by using the agent lifecycle methods - Made SimpleProfileRegistry implement IAgentService, so it can ensure profile preference save jobs are completed when the registry is removed from the agent or the agent shuts down Various changes in the test suites where it was making assumptions about agent lifecycle being the same as bundle lifecycle.
I have released this in HEAD.
This wasn't quite sufficient. The problem is that the agent is now stopped very late during shutdown, but services should really be cleaning themselves up when their DS component goes away. I have changed ProvisioningAgent to track the factory services that it uses, and automatically remove the associated services from the agent when that factory goes away. This makes the agent dynamic - it can handle bundles coming and going that provide or withdraw agent services. It's not clear we need this full dynamic behaviour, but something like this is needed during shutdown anyway so it felt worth doing it.
Created attachment 158912 [details] Additional changes to track service removals
Fixed in HEAD.