Free tutorials for Java, Eclipse and Web programming



Follow me on twitter

Eclipse Modeling Framework (EMF) - Persisting models via XMI

Lars Vogel

Version 0.3

30.01.2011

Revision History
Revision 0.1 20.01.2010Lars Vogel
split from main EMF article into own article
Revision 0.2 - 0.3 01.03.2010 - 30.01.2011Lars Vogel
bug fixes and enhancements

Persistence with Eclipse EMF

This tutorial describes how to persists Eclipse EMF in XMI (XML). This article is based on Eclipse 3.6 (Helios).


Table of Contents

1. Persisting EMF models via XMI
2.
2.1. Example
2.2. Load an existing model
3. Appendix: Encryption
4. Thank you
5. Questions and Discussion
6. Links and Literature
6.1. Source Code
6.2. EMF Resources
6.3. vogella Resources

1. Persisting EMF models via XMI

EMF allows to store the model content via the EMF persistence framework. EMF provides XMI and XML persistence provider. By default EMF uses XMI (XML Metadata Interchange). XMI is a standard for exchanging metadata information via Extensible Markup Language (XML).

The following demonstrates how you create a EMF model instance, save it and load it again.

If you persistent an EMF object all dependent object will automatically be persistent. Objects which do not have a "contains relationship" must be added explicitly to the resource.getContents().add(). If objects are not added and not included in a contains relationship an exception is thrown when calling resource.save()

This article focus on the persistence of EMF models via XMI. For an introduction into Eclipse EMF please see Eclipse EMF .