getting OSGI Bundle from Eclipse IConfigurationElement

Posted by Hayden Marchant on Stack Overflow See other posts from Stack Overflow or by Hayden Marchant
Published on 2010-06-15T09:01:01Z Indexed on 2010/06/15 9:42 UTC
Read the original article Hit count: 225

Filed under:
|

Hi there,

I am looking for extensions that implement a specific extension point, and am using the following acceptable method to do this:

IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); if (extensionRegistry == null) { return TEMPLATES; }

IConfigurationElement[] config = extensionRegistry.getConfigurationElementsFor("com.ibm.im.launchpoint.templates.template");

I then would like to get the version of the defining bundle. I would use the following API, but the API for PluginVersionIdentifier is deprecated:

for (IConfigurationElement e : config) { BlueprintTemplate template = new BlueprintTemplate();

IExtension declaringExtension = e.getDeclaringExtension(); PluginVersionIdentifier versionIdentifier = declaringExtension.getDeclaringPluginDescriptor().getVersionIdentifier();

I could not find an alternative in the new API - i.e. from a IConfigurationElement, how do I get the version id descriptor of the bundle. Obviously, from the Bundle I can get the version using the Bundle.getHeaders(), getting the Bundle-Version value - but how do I get the Bundle in the first place??? Platform.getBundle(bundleId) is not enough since I might have multiple versions of same bundle installed, and I need to know who I am. At the moment I have a chicken & egg situation, and the only solution I have is the above deprecated API.

© Stack Overflow or respective owner

Related posts about eclipse

Related posts about osgi