简体   繁体   English

如何访问plugin.xml中的数据?

[英]How to access data inside the plugin.xml?

I am currently developing a Java RCP with Eclipse RCP which has a plugin.xml where one can find information like ID , version , Name , plattform , and so on.... 我目前正在用Eclipse RCP开发Java RCP ,它具有plugin.xml ,在其中可以找到IDversionNameplattform等信息。

Now, my question is, whether it is possible to somehow access the plugin.xml from my java code. 现在,我的问题是,是否有可能通过我的Java代码访问plugin.xml Is it for example possible to load the ID into a therefor created variable? 例如,是否可以将ID加载到为其创建的变量中?

edit I want to access the ID you can find when you open the plugin.xml file with the plug-in manifest editor. 编辑我想访问使用插件清单编辑器打开plugin.xml文件时可以找到的ID I tried the approach with Platform.getBundle("plugin.xml") , but I only received an object refering to null . 我使用Platform.getBundle(“ plugin.xml”)尝试了该方法,但是我只收到一个引用null的对象。

edit2 I also tried Platform.getProduct().getId(); edit2我也尝试了Platform.getProduct()。getId(); but it seems getProduct() also returns null . 但似乎getProduct()也返回null Does anyone have a clue why those two approaches mentioned above do not work? 有谁知道为什么上述两种方法不起作用? Or does anyone have a proper solution for accessing the ID ? 还是有人有访问ID的适当解决方案?

Thanks in advance. 提前致谢。

Regards, kain 问候,凯恩

You can use Platform.getBundle("symbolic.name") to get the reference to your plugin. 您可以使用Platform.getBundle(“ symbolic.name”)来获取对插件的引用。 You can get version number and id from the Bundle object. 您可以从Bundle对象获取版本号和ID。 http://www.osgi.org/javadoc/r4v43/org/osgi/framework/Bundle.html http://www.osgi.org/javadoc/r4v43/org/osgi/framework/Bundle.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM