getting OSGI Bundle from Eclipse IConfigurationElement -


I have the extension that is implementing a particular extension point, and using the following acceptable method to do this :

IExtensionRegistry Extension Registry = Platform.getExtensionRegistry (); If (extensionRegistry == zero) {return templates; }

IntegralEngineering

I want to get the version of defined bundles. I would use the following API, but the API for PluginVersionIdentifier is no longer valid:

(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 - from an IConfigurationElement i.e., how do I get the bundle version ID descriptor. Obviously, with the bundle I can get the version of the bundle. Getting Gate-Headers (), bundle-version value - but how do I get bundles in the first place ??? Platform.getBundle (bundle id) is not enough because I can have multiple versions of the same bundle installed, and I have to know who I am. At the moment I have chicken & amp; Egg status, and the only solution I have is the deprecated API.

After the

All this information is based on 3.6 Assume:

Your IContributor An example of will be RegistryContributor if you are in the OSGi environment where you are definitely or you will not be concerned about this problem

Registry ContentsBu let you Returns the methods: getID () and getActualID () . getID () The host could return the bundle if it was loaded with a piece. getActualID () Contributor's fragment / bundle id always loads You can use your ID in your BundleContext.getBundle (long id) method. Here's a snippet:

  Bundle bundle; If (Example of Contributor to Registration Content) {long id = long.parseLong ((Registry Contentubtator Contributor) .getActualId ()); Bundle this bundle = FrameWorldTool. Gate bundle (getClass ()); Bundle = thisBundle.getBundleContext (). GetBundle (ID); } And {bundle = platform. Gate Bundle (Contributor .getName ()); }  

I use a fall through the method which would be extremely inconvenient for any non-version aware solution in the future if the IContributor gets a new default implementation. Bundle ID Unique to an example of OSGI so that it loads the correct version of the bundle.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -