ID-based persistence of EReferences to enable reliable cross-resource references.
Problem
- By default, EMF uses XPath-like links to persist EReferences.
- While this works fine for standalone model resources, it can cause inconsistencies in case there are multiple resource models that contain cross-resource references. (I.e., if the structure of the AF3 model resource changes, the links from the external model resource can become invalid)
- The recommended way to work around this is to configure EMF to use unique IDs to encode EReferences.
Implementation for AF3 model resource
- Declare org.fortiss.tooling.kernel.model.IIdLabled an EMF id (assumption: IIdLabled is used as base interface for any model element that is persisted)
- AF3 already has the machinery to assign unique IDs
- Configure a cache to speed up EReference lookups (already forseen by EMF)
- Investigate source of ID duplications that have been observed (very rare), and provide a counter-measure (e.g., model validator) since the uniqueness of IDs will become crucial for model loading.
Thanks to EMF, the resulting change is forward and backward compatible, i.e. models with XPath-like encoded ERefernces can be loaded after the change, and even models with IDs-based encoded EReferences can be loaded by older AF3 releases (in case the rest of the meta-model did not change, of course)
(from redmine: issue id 2309, created on 2015-03-12, closed on 2015-03-17)