Using Eclipse EMF/Ecore models inside the Eclipse Platform is quite easy. Loading an XML/XMI serialized model file is only a matter of some lines of code. The most interesting thing about this is that the whole Eclipse platform can handle the registration of models and model factories for you. So instead of knowing what model type you are loading, it will be detected and the right model factory will be used for loading and creating your model instance. Even better is the fact that also derived model objects can be loaded that way.
Just image you are writing a model A and extend object in the model B. So you can create a model instance which contains objects from model A and B and just serialize it to XML. Loading it back will of course give you model objects of type A and B. Although initially only model A existed and B was an extension using derivation. For this to work the resource mechanism of EMF must need to know which namespace is handled by which resource package and factory. If you are running inside an Eclipse Platform this is easily done using the extension mechanism. And the “genmodel” file and generator will automatically create the correct code and “plugin.xml” for this setup.
The problems start when you are outside the Eclipse Platform and running in a plain Java application. The default way to go is by registering all EMF models somewhere before loading the serialized models:
public void setup () {
MyModelPackage.eINSTANCE.eClass();
}