[ATL]Instances of EMF-generated models as ATL outputs? [message #65839] |
Thu, 08 November 2007 13:06 |
Eclipse User |
|
|
|
Originally posted by: matt.mcgill.gmail.com
Hello all,
I have an EMF model MM (conforming to Ecore) that is the metamodel for
the output of an ATL transformation T. In other words, T produces
instances of MM as output. I have used EMF to generate Java code for A.
So, for class Foo in MM there is now a generated Java class called
FooImpl, along with generated Java classes MMPackageImpl and
MMFactoryImpl and others. In this scenario I am executing ATL
programmatically and standalone, not from the Eclipse menu or within the
Eclipse runtime via Ant tasks.
When I execute T, I expect to receive as output an ASMEMFModel wrapping
an EMF Resource containing instances of my generated classes such as
FooImpl. However, the resource contained by the ASMEMFModel representing
the output of T instead contains DynamicEObjectImpl instances, even
though I have registered MM prior to executing T by referencing
MMPackage.eINSTANCE. Presumably ASMEMFModel is not finding the generated
MMFactoryImpl to create model elements with. What do I need to do to
cause ATL to use the generated factory when creating target model elements?
Note that, after executing the transformation, I can serialize the
resulting output model to XMI and then reload it with the following code:
ByteArrayOutputStream out = new ByteArrayOutputStream();
/* serialize model as XMI to out */
Resource r = new XMIResourceImpl();
try {
r.load(new ByteArrayInputStream(out.toByteArray()),
new HashMap<String, String>());
} catch (IOException ex) {
throw new RuntimeException(ex);
}
FooImpl foo = (FooImpl)r.getContents().get(0);
and in this manner convert the DynamicEObjectImpls to FooImpls - but it
is very undesirable to have to do this.
Thanks,
-Matt McGill
|
|
|
Powered by
FUDForum. Page generated in 0.07124 seconds