georgiana_e
georgiana_e

Reputation: 1869

EclipseRCP get pluginId in which a class is located

I have an objects of class T that belongs to plugin P. It is possible to retrieve the Plugin ID, trough class T?

I don't have access to plugin object but I have access to a objects that is an inner class of plugin P, I have access to PluginClassDescriptor. I have access to:

P.T object; // I need P.pluginID

Thanks

Upvotes: 0

Views: 215

Answers (1)

greg-449
greg-449

Reputation: 111141

You can get the Bundle for any plug-in class using:

Bundle bundle = FrameworkUtil.getBundle(anyobject.getClass());

where `anyobject' is an instance of some class belonging to the plug-in.

The plug-in id is known as the 'symbolic name' in the bundle:

String pluginid = bundle.getSymbolicName();

FrameworkUtil is org.osgi.framework.FrameworkUtil in the org.eclipse.osgi plug-in.

Upvotes: 1

Related Questions