Bryji
Bryji

Reputation: 1296

List eclipse installed plugins at runtime

Here's something obvious that should be easy to do...

How do I retrieve a list of installed plugins at runtime? Can't see an obvious way to do this a Platform.getBundle() requires a specific plugin name.

Is this perhaps a restriction for some kind of security reason?

Upvotes: 16

Views: 9740

Answers (2)

VonC
VonC

Reputation: 1323753

From here:

The BundleContext class has a getBundles() method that returns all installed bundles.

You get an instance of the BundleContext when your bundle is activated BundleActivator.start(BundleContext)).

You can use it to get some Bundle version number for instance.

http://t-templier.developpez.com/tutoriel/java/osgi/osgi1/images/architecture-osgi-haut-niveau.png

The interactions between the bundles are done through two complementary mechanisms: the package export/import and the service registration lookup facility.

http://sfelix.gforge.inria.fr/osgi-security/images/osgi/osgi_interoperability.png

The publication and lookup of services are performed through the BundleContext reference that each bundle receives at startup time.
During the publication process, the advertising bundles registers a service by publishing a Java interface it is implementing, and by providing a class implementing this interface.
The lookup is performed by the client bundle, which gets the service from the BundleContext and uses it as a standard Java object.

Upvotes: 12

Scott Stanchfield
Scott Stanchfield

Reputation: 30644

If you're looking to write this in your code, see VonC's answer.

If you just want a view that does this, there's already one in eclipse: Window->Show View->Other...->PDE Runtime->Plugin Registry. This displays plugins, their extensions, dependencies, and who is providing extensions.

Upvotes: 4

Related Questions