问题
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?
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/9383880/loading-same-plugin-twice-with-different-version-in-eclipse