Resolving Proxy EMF Elements
EMF / Ecore / openArchitectureWare
EMF supports cross-referencing between documents; these elements will be provided at runtime as EObjects with eProxyURI set. You can try and resolve the proxy object using EcoreUtil.resolve(EObject, Resource)
, but this might not always work.
As the EMF book fails to describe, but the newsgroup does, a common mistake is to load the original Resource using a relative URI instead of an absolute URI.
That is:
String filename = "model/test.model";
ResourceSet resourceSet = new ResourceSetImpl();
URI uri = URI.createFileURI(filename);
Resource resource = resourceSet.getResource(uri, true);
Should be:
String filename = new File("model/test.model").getAbsolutePath();
ResourceSet resourceSet = new ResourceSetImpl();
URI uri = URI.createFileURI(filename);
Resource resource = resourceSet.getResource(uri, true);