在 Eclipse 中使用不同版本加载相同插件两次
我有两个不同版本的 EMF 插件,它们加载某个 .xmi。后一个版本已更改,因此与前一个版本的 xmi 不兼容。我想要做的是使用第一个插件加载 xmi,然后使用较新的插件以编程方式构建模型,从而迁移旧模型。除了 EMF 模型中的一些变化之外,它们是相同的。
我如何加载这些插件?是否可以?有更好的策略吗?
I have two different versions of an EMF plugin which loads a certain .xmi. The latter version has been changed so that the xmi from the previous version is incompatible. What I want to do is to load the xmi's with the first plugin and then programatically build a model using the newer plugin thus migrating older models. They are identical apart from some changes within an EMF model.
How do I load these plugins? Is it possible? Are there better strategies?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议更改旧版本的 id(可能还有 EMF 包 URI),这样您就可以同时拥有两个代码和模型。
由于您需要在同一个插件(迁移器)中处理旧类和新类,因此无法同时工作。
但是,您应该查看动态 EMF 技术,您可以在其中打开没有生成包的旧模型(另一方面,您必须使用反射 API)。使用此方法,您可以编写一个转换器,使用 EMF 反射 API 打开旧模型,并手动将其转换为新模型版本。
I suggest changing the id of the old version (and possibly the EMF package URI), so you can have the two code and models simultaneously.
As you need to handle both old and new classes in the same plug-in (the migrator), there is no way you can have both working.
However, you shall look at the dynamic EMF technology where you could open the old model without its generated packages (on the other hand, you have to use the reflective API). Using this method you can write a converter, that opens the old model using EMF reflective API, and manually translate it into your new model version.
抱歉,但这是不可能的,因为这些插件是单例的。而且您无法在迁移期间切换插件,因为 Java 基类会妨碍您。
一种可能的解决方案是使用 EDapt 技术。该技术允许您在加载模型时自动迁移模型。我在两个不同的项目中使用了 COPE(EDapt 的前身),并取得了巨大成功。
Sorry, but that is not possible as these plug-ins are singletons. And you cannot switch the plug-ins during the migrations as the Java base classes gets in your way.
One possible solution is using the EDapt technology. This technology allows you to automatically migrate you model as you load it. I have used COPE - the predecessor of EDapt - in two different projects with great success.