[Edapt] Own EDataType and Factory [message #1647891] |
Tue, 03 March 2015 17:05 |
Dennis Melzer Messages: 244 Registered: July 2009 |
Senior Member |
|
|
Hello,
I override the createFromString in the EFactory Methode to instantiate a own EDataType. But if Edapt load a resourceset and overrides the registered package and use instead of my efactory the normal EFactory and cannot instantiate the own EDataTyp
public Foo createFooObjectFromString(EDataType eDataType, String initialValue)
{
return new Foo(initialValue);
}
ResourceSet for the Migrator
private static class XMLResourceSetFactory implements IResourceSetFactory {
@Override
public ResourceSet createResourceSet() {
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put("OldPackageUri", ConfigPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
.put("xml", new ConfigResourceFactoryImpl());
return resourceSet;
}
}
Edapt Code ResourceUtils:
ResourceSet resourceSet = resourceSetFactory.createResourceSet();
// Do not register ePackages if not set.
if (ePackages != null)
register(ePackages, resourceSet.getPackageRegistry());
...
private static void register(List<EPackage> ePackages, Registry registry,
Map<String, EPackage> backup) {
for (EPackage p : ePackages) {
String nsURI = p.getNsURI();
EPackage old = (EPackage) registry.put(nsURI, p); --> override my package impl
backup.put(nsURI, old);
register(p.getESubpackages(), registry, backup);
}
}
How can i set the right (own) Factory for Edapt when the migrator loads the model?
Thanks
Dennis
|
|
|
Re: [Edapt] Own EDataType and Factory [message #1651518 is a reply to message #1647891] |
Thu, 05 March 2015 10:50 |
|
Hi Dennis,
We added an extension point to register custom efactories for a specific ns-uris recently.
This should work for use case. You have to pay attention that the switch made in createFromString is not based on the classifierId however, because the ids might be different in the dynamic EPackage created by Edapt.
The extension point id is org.eclipse.emf.edapt.factories
<extension
point="org.eclipse.emf.edapt.factories">
<factory
class="org.example.MyEcoreFactory"
nsURI="http://www.eclipse.org/emf/2002/Ecore">
</factory>
</extension>
Best regards
Johannes
Johannes Faltermeier
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04772 seconds