Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] identity of EClass instances in ASMEMFModel.loadASMEMFModel?
[ATL] identity of EClass instances in ASMEMFModel.loadASMEMFModel? [message #81973] Wed, 21 May 2008 21:17
Bruno Haible is currently offline Bruno HaibleFriend
Messages: 8
Registered: July 2009
Junior Member

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.loadASMEMFModel("extlibrary", metaModel,
sourceModelFile, loader);

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


the call


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 on_archive/1021.html

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
EClass instances?

Previous Topic:[ATL] transformation with JMI
Next Topic:[ATL] Multiple metamodels for a single source file. possible?
Goto Forum:

Current Time: Thu Oct 01 09:13:57 GMT 2020

Powered by FUDForum. Page generated in 0.01928 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top