特定于体系结构的 Eclipse 插件片段
在构建使用 OS.getRegOpenKey(...) 的 RCP 插件时,我需要同时针对 win32.x86 和 win32.x86_64 体系结构。对于两种体系结构,该方法的参数类型不同。
我现在明白,没有直接的方法可以让 x86 或 x86_64 片段(取决于构建)覆盖我的主机插件中的方法。
然而,从 这篇文章 看来,片段可以添加一个扩展类的类在主机中。然后,主机插件可以显式地使用 ClassLoader 从该架构构建中包含的片段中查找并实例化正确的子类。这会是什么样子?
I need to target both win32.x86 and win32.x86_64 architectures when building an RCP plug-in that uses OS.getRegOpenKey(...). The types of the arguments for the method are different for the two architectures.
I understand now that there is no straightforward way to have an x86 or x86_64 fragment (depending upon the build) override a method in my host plug-in.
However, from this post it sounds like a fragment can, for example, add a class that extends a class in the host. And the host plugin can then explicitly use the ClassLoader to find and instantiate the correct subclass from the fragment included in that architecture's build. What would this look like?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据链接的帖子,这就是我到目前为止所拥有的(现在两种架构的构建都没有错误,我只需要看看构建的 64 位应用程序是否可以在 64 位 Windows 上运行!):
使用 Eclipse 的片段用于创建 x86 和 x86_64 片段的插件向导。清单中有几行手动添加的额外行。例如,x86_64 片段的 Manifest.mf 的重要部分:
然后,向片段添加子类(使用与主机插件中的超类相同的包名称,但这可能不是必需的):
与OSUtilities32 类。
将片段添加到包含主机插件的 feature.xml 中:
然后主机插件可以静态加载适当的可用类:
稍后我应该使用体系结构系统属性来选择要实例化的类。
Based on the linked-to post, this is what I have so far (builds without error now for both architectures, and I just need to see if the built 64-bit app will run on 64-bit Windows!):
Use Eclipse's fragment plug-in wizard to create the x86 and x86_64 fragments. The manifests have a couple of extra lines manually added. For example, the important bits of the x86_64 fragment's Manifest.mf:
Then, added subclass to the fragment (used the same package name as the super class from the host plug-in, but that probably isn't necessary):
Same for the OSUtilities32 class.
Added the fragments to the feature.xml containing the host plug-in:
Then the host plug-in can statically load the appropriate, available class:
I should use the architecture system property to pick which to instantiate -- later.