Get real Instance of DynamicEObjectImpl [message #488609] |
Tue, 29 September 2009 08:51  |
Eclipse User |
|
|
|
Hello,
I am working with EMF and oAW Code Generation.
When putting my EMF Element from oAW into Java code I get a DynamicEObjectImpl object instead of real Class instance.
I tried following w/o success:
if(param instanceof DynamicEObjectImpl)
{
DynamicEObjectImpl test = (DynamicEObjectImpl)param;
Object element=DdfFactory.eINSTANCE.create(test.eClass());
System.out.println(element);
if(element instanceof SectionNode)
{
SectionNode secNode = (SectionNode)element;
......
}
}
Maybe anybody has a hint how to get the class instance of my DynamicEObjectImpl.
Sincerly
Patrick
|
|
|
Re: Get real Instance of DynamicEObjectImpl [message #488611 is a reply to message #488609] |
Tue, 29 September 2009 09:07   |
Eclipse User |
|
|
|
Hi Patrick,
I'm not quite familiar with oAW code generation. But I think the following excerpt (taken from "Using Dynamic EMF" at http:// www.openarchitectureware.org/pub/documentation/4.3.1/html/co ntents/emf_tutorial.html) might give you a hint:
Quote: |
Note that openArchitectureWare can work completely with dynamic models, there is no reason to generate code. However, if you want to programmatically work with the model, the generated metaclasses (not the editors!) are really helpful. Please also keep in mind: in subsequent parts of the tutorial, you will specify the metaModelPackage in various component configurations in the workflow file, like this:
<metaModel id="mm"
class="org.openarchitectureware.type.emf.EmfMetaModel">
<metaModelPackage value="data.DataPackage"/>
</metaModel>
In case of dynamic EMF, there has no metamodel package been generated. So, you have to specify the metamodel file instead, that is, the .ecore file you just created. Note that the .ecore file has to be in the classpath to make this work.
<metaModel id="mm"
class="org.openarchitectureware.type.emf.EmfMetaModel">
<metaModelFile value="data.ecore"/>
</metaModel>
|
Best regards,
sas
|
|
|
Re: Get real Instance of DynamicEObjectImpl [message #488625 is a reply to message #488611] |
Tue, 29 September 2009 09:58   |
Eclipse User |
|
|
|
Thats not the point, in this its just the description how to use ecore models in oAW.... Thanks anyway
News.sascha.gessler.googl wrote on Tue, 29 September 2009 09:07 | Hi Patrick,
I'm not quite familiar with oAW code generation. But I think the following excerpt (taken from "Using Dynamic EMF" at http:// www.openarchitectureware.org/pub/documentation/4.3.1/html/co ntents/emf_tutorial.html) might give you a hint:
Quote: |
Note that openArchitectureWare can work completely with dynamic models, there is no reason to generate code. However, if you want to programmatically work with the model, the generated metaclasses (not the editors!) are really helpful. Please also keep in mind: in subsequent parts of the tutorial, you will specify the metaModelPackage in various component configurations in the workflow file, like this:
<metaModel id="mm"
class="org.openarchitectureware.type.emf.EmfMetaModel">
<metaModelPackage value="data.DataPackage"/>
</metaModel>
In case of dynamic EMF, there has no metamodel package been generated. So, you have to specify the metamodel file instead, that is, the .ecore file you just created. Note that the .ecore file has to be in the classpath to make this work.
<metaModel id="mm"
class="org.openarchitectureware.type.emf.EmfMetaModel">
<metaModelFile value="data.ecore"/>
</metaModel>
|
Best regards,
sas
|
|
|
|
|
|
|
|
|
Re: Get real Instance of DynamicEObjectImpl [message #488785 is a reply to message #488770] |
Wed, 30 September 2009 04:47  |
Eclipse User |
|
|
|
Patrick Schmitt wrote:
> Okey, so i will describe it better...
>
> - I created a ecore model and from that a genmodel... - Then I
> generated the model code, edit code and editor code, started the
> editor and build a model based on my ecore.
> - After that i created a mwe workflow using the xmi reader and xpand2
> generator to create code of my model.
>
> In my Xpand file i tried to put the the Section Node instance to my
> java code:
>
> «DEFINE menuNodeStruct FOR SectionNode»
> static node DDF_MENUNODE _node«setMenuNodeID(this)»«this.nodeID»
> «EXPAND menuNodeStruct FOREACH this.menuNode»
> «ENDDEFINE»
>
>
> Xtend:
>
> import ddf;
> Void setMenuNodeID(ddf::SectionNode item): JAVA
> ddf.core.helper.setMenuNodeID(ddf.SectionNode)
>
>
> Problem is that the SectionNode i give as parameter to the java
> function is no real object, its just a DynamicEObjectImpl instance.
>
> I dont know how to get the real instance of my SectionNode...
I'm not sure under the covers how the instance is being read by oAW.
What EMF itself does is look at the XML namespace of the root element
and it tried to use
EPackage.Registry.INSTANCE.getEPackage(<namespace>). Whatever that
returns is used to resolve names in that namespace and ultimate the
factory of that package is used to create all the instances.
Therefore, your generated package needs to be registered. I'm not sure
how to ensure that this happens in your oAW environment. In an OSGi
application, the plugin.xml registry normally ensure this is done.
>
> Hope now you better understand my intention,
>
> Kind Regards
> Patrick
|
|
|
Powered by
FUDForum. Page generated in 0.26528 seconds