I think the trick here is to track all bundles that are NOT in the UNINSTALLED state. Then do your processing in the modifiedBundle method of your customizer. You still need to handle pre-existing bundles when you open your tracker. You can do that as a separate call to your customizer after you have opened the tracker. If this does not work for you then you are left implementing your own SynchronousBundleListener. We had a similar report in Equinox ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=383828)
Tom From: Tim Diekmann <[email protected]> To: [email protected] Date: 09/30/2014 07:24 PM Subject: [osgi-dev] Start a bundle from BundleTrackerCustomizer.addingBundle() Sent by: [email protected] Hi, I’m looking for a solution, but cannot come up with one. Here is the scenario: I have a BundleTracker to track bundles with a certain header, i.e. implementing an extender. The extender is interested in RESOLVED|STARTING|ACTIVE|STOPPING. When a bundle is installed, but not started, the addingBundle() is called and the extender processes the bundle. Now, I want to start the bundle based on whether it is configured to be started or not, i.e. I am looking at CM configuration to determine whether to start the bundle or not. Now, here’s the problem: You cannot start the bundle in the callback of BundleTrackerCustomizer.addingBundle(). If you do, the bundle will start, but your Tracker will not receive any events for the Bundle, since it hasn’t returned yet from the addingBundle() callback to indicate interest in the Bundle. What I need here is to be able to return from the addingBundle() callback to indicate interest and then trigger the start of the Bundle. How do I do that? This is event driven. The callback to addingBundle() is the main event. Now, I need another event that the bundle is tracked in order to trigger the start such that the same extender BundleTrackerCustomizer starts receiving the events for the start of the Bundle. Any ideas, anyone? Thanks, Tim. P.S: I doubt that setting the start level would help here. Since the BundleTrackerCustomizer.addingBundle() call hasn’t returned yet, it will not receive any events for the Bundle. Even if the start level is changed by another thread, there is no guarantee that the BundleTracker returns before the start level thread starts the bundle. _______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
