How to find plugin id in eclipse rcp application
In every plugin class, you must have your private instance variable for your plugin and you must implement the getInstance () method to return an instance reference, I believe you should already be doing this if you don't see the docomentaion reference for the Plugin class. After YorPluginClass1.getInstance().getBundle().getSymbolicName();
and YorPluginClass2.getInstance().getBundle().getSymbolicName();
should be specified that their respective symbolic plugin names should be returned.
source to share
I am using the following code in one of mine Activators
:
/**
* Returns the bundle id of the bundle that contains the provided object, or <code>null</code>
* if the bundle could not be determined.
*
* @param clazz the object to test
* @return the build ID or <code>null</code>
*/
public String getBundleId(Class<? extends Object> clazz) {
if (clazz == null) return null;
final PackageAdmin packageAdmin = getBundleAdmin();
if (packageAdmin == null) return null;
final Bundle source = packageAdmin.getBundle(clazz);
if (source == null || source.getSymbolicName() == null) return null;
return source.getSymbolicName();
}
/**
* Returns the OSGi Package Admin service, if available.
*/
public PackageAdmin getBundleAdmin() {
if (bundleTracker == null) {
bundleTracker = new ServiceTracker(getContext(), PackageAdmin.class.getName(), null);
bundleTracker.open();
}
return (PackageAdmin) bundleTracker.getService();
}
And yes, I know it is PackageAdmin
outdated, but I didn't have time to update it ...
source to share