我寻找实现特定扩展点的扩展,并且正在使用以下可以接受的方法来做到这一点:在Eclipse IConfigurationElement得到OSGI包
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();如果(extensionRegistry == null){ return TEMPLATES; }
IConfigurationElement [] config = extensionRegistry.getConfigurationElementsFor(“com.ibm.im.launchpoint.templates.template”);
然后我想要获取定义包的版本。我将使用以下API,但不推荐使用API PluginVersionIdentifier:
(IConfigurationElement e:config)BlueprintTemplate template = new BlueprintTemplate();
IExtension declaringExtension = e.getDeclaringExtension(); PluginVersionIdentifier versionIdentifier = declaringExtension.getDeclaringPluginDescriptor()。getVersionIdentifier();
我无法在新的API中找到替代方案 - 即从IConfigurationElement中,我如何获取捆绑的版本ID描述符。显然,从Bundle中我可以使用Bundle.getHeaders()获得版本,获得Bundle-Version值 - 但是我怎样才能获得Bundle呢? Platform.getBundle(bundleId)是不够的,因为我可能安装了同一个bundle的多个版本,我需要知道我是谁。目前,我有一个鸡蛋情况,我唯一的解决方案是上面的弃用API。
再次,这并没有真正帮助我,因为可能会有多个包含该ID的捆绑包,但只有其中一个包含了该扩展的定义。 另一点,Bundle没有getVersion方法。 我需要的原因是我正在注册一个'文档模板'作为扩展点,并且可能有此模板的不同版本。所以当模板加载时,我想知道它是哪个版本,用于记号等等。现在,我在模式中为扩展点使用了一个额外的属性,这是一个耻辱。 – 2010-06-21 06:06:34
我认为,这个额外的属性是更好的解决方案。通过这种方式,可以在不更新扩展版本的情况下更新插件,也无需修改接收器即可更新新版本。 有趣的是,该包不包含getVersion()方法。也许这是Eclipse 3.6中的一个新方法,我在研究贡献者时使用了它。 – 2010-06-21 07:55:04