Reputation: 961
I am writing an application that uses Equinox as my OSGi framework. I am trying to discover all of the bundles that are known at the time that my bundle is registered. I attempted to use the following line to retrieve all of the available bundles. However,
EclipseStarter.getSystemBundleContext().getBundles();
gives me a warning of...
Discouraged access: The method getSystemBundleContext() from the type EclipseStarter is not accessible due to restriction on required library D:\java\eclipse\plugins\org.eclipse.osgi_3.4.0.v20080605-1900.jar
What is the proper usage to get a list of all of the available bundles within the framework?
Upvotes: 0
Views: 1343
Reputation: 4164
You could use your own bundle context as an entry point instead of the EclipseStarter - in your plugin activator:
start(BundleContext context)
{
context.getBundles(); // what you want
}
Look at the Plugin
cans AbstractUIPlugin
classes if you don't know about them.
If you really need singleton access, your plugin is probably one - feel free to expose YourPlugin.getInstance().getBundleContext()
.
(Disclaimer: I haven't tried it - but it would be consistent with OSGi/Eclipse)
Upvotes: 2