Dynamic EMF [message #423167] |
Wed, 24 September 2008 05:49  |
Eclipse User |
|
|
|
Hello!
I like the functionality of dynamic creation of meta models. But it
seems to me, that the creation of the model should be finished before
the first instances are created!?
Example:
EPackage myDynamicPackage = EcoreFactory.eINSTANCE.createEPackage();
myDynamicPackage.setName("coolPackage");
EClass myClass = EcoreFactory.eINSTANCE.createEClass();
myClass.setName("My Name");
myDynamicPackage.getEClassifiers().add(myClass);
EObject inst = EcoreUtil.create(myClass);
EAttribute myAttribute = EcoreFactory.eINSTANCE.createEAttribute();
myAttribute.setName("attribute1");
myAttribute.setEType(EcorePackage.eINSTANCE.getEString());
myClass.getEStructuralFeatures().add(myAttribute);
inst.eSet(myAttribute, "attValue1");
EAttribute myAttribute2 = EcoreFactory.eINSTANCE.createEAttribute();
myAttribute2.setName("attribute2");
myAttribute2.setEType(EcorePackage.eINSTANCE.getEString());
myClass.getEStructuralFeatures().add(myAttribute2);
inst.eSet(myAttribute2, "attValue2");
The second eSet generates an ArrayIndexOutOfBoundsException.
Is this meant to be or perhaps a bug?
Thanks,
Kristian
|
|
|
|
|
Re: Dynamic EMF [message #423181 is a reply to message #423179] |
Wed, 24 September 2008 10:03  |
Eclipse User |
|
|
|
Kristian,
I suppose the EStore could be used for such a purpose, but the primary
purpose for it is to separate out all the data values from the objects
themselves such that the object act merely as a facade and all data
management is handled by the store. CDO is a great example of how it
can be used to support facade objects where the real backing model is on
the server rather than the client.
Kristian Sons wrote:
> Ed,
>
> thanks for the answer!
>
>>> EPackage myDynamicPackage = EcoreFactory.eINSTANCE.createEPackage();
>>> myDynamicPackage.setName("coolPackage");
>> Settings an nsURI is important as well.
>
> Of course.
>
>>> Is this meant to be or perhaps a bug?
>> Until we implement
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=177107, i.e., a
>> specialized EObjectImpl subclass that's tolerant of changes to the
>> metamodel, it's just meant to be.
>
> Great! When is it available ;)
>
> I saw the Estore stuff in EObjectImpl. Is this meant to become
> something like this?
>
> Kristian
|
|
|
Powered by
FUDForum. Page generated in 0.04890 seconds