Using Dynamic EMF

Using Dynamic EMF

Instead of generating editors and metaclasses, you can also use dynamic EMF. This works by selecting, in the opened metamodel, the root class of the model you want to create (here: DataModel ) and then selecting Create Dynamic Instance from the context menu. This opens an editor that can dynamically edit the respective instance. The created file by default has an .xmi extension.

Note that Xpand can work completely with dynamic models, there is no reason to generate code. However, if you want to programmatically work with the model, the generated metaclasses (not the editors!) are really helpful. Please also keep in mind: in subsequent parts of the tutorial, you will specify the metaModelPackage in various component configurations in the workflow file, like this:

<metaModel id="mm"
  class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
  <metaModelPackage value="data.DataPackage"/>
</metaModel>

In case of dynamic EMF, there has no metamodel package been generated. So, you have to specify the metamodel file instead, that is, the .ecore file you just created. Note that the .ecore file has to be in the classpath to make this work.

<metaModel id="mm"
  class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
  <metaModelFile value="data.ecore"/>
</metaModel>