|[ATL] identity of EClass instances in ASMEMFModel.loadASMEMFModel? [message #81973]
||Wed, 21 May 2008 21:17
| Bruno Haible
Registered: July 2009
Is there any way to create an ASMEMFModel from a *.ecore file,
while at the same time reusing the EClass instances already in memory
from an EMF-generated Ecore model?
I have a set of Java classes, generated by EMF for an Ecore model.
I also have a set of instances of these Java classes, and wish to use
them as input to an ATL transformation, without serializing to XML and
The source model is in fact the 'extlibrary' model from the
org.eclipse.emf.examples.library plugin; nothing of my own.
When I use the following code:
Library lib = EXTLibraryFactory.eINSTANCE.createLibrary();
URL sourceModelFile =
AtlEMFModelHandler modelHandler =
ASMEMFModel metaModel = (ASMEMFModel)modelHandler.getMof();
EMFModelLoader loader = new EMFModelLoader();
ASMEMFModel sourceModel =
ASMEMFModel source =
(ASMEMFModel)loader.newModel("IN", "IN", sourceModel);
the 'lib' variable will be an instance of LibraryImpl, and its
Ecore class is an instance of EClassImpl which has a non-null
'instanceClass' field (namely the LibraryImpl class).
The loadASMEMFModel statement, however, creates new EClassImpl
instances. The EClassImpl for "Library" created here will have a
null 'instanceClass' field and a null 'instanceClassName' field.
This has the negative effect that when I add the 'lib' object
to the 'source' model, it will not be recognized correctly:
After I do
still returns null, because from the string "Library" it
fetched the EClassImpl that was created during loadASMEMFModel,
which is *different* from the class to which the 'lib' object
I can not use the 'source' model as input to ATL in such a
situation - the ATL output is empty.
I believe this is the same problem as mentioned in
The same problem is also blocking on the target side: I want
to generate instances of an EMF-compiled target model, not
instances of org.eclipse.emf.ecore.impl.DynamicEObjectImpl;
the latter is likely to be the outcome when instantiating an EClass
which has a null 'instanceClass' and null 'instanceClassName'.
What's the solution? Can loadASMEMFModel be made to reuse existing
Powered by FUDForum
. Page generated in 0.01377 seconds