Dynamic extension of EMF model and getEAllStructuralFeatures [message #686974] |
Thu, 19 May 2011 12:32 |
Daniel Selman Messages: 14 Registered: July 2009 |
Junior Member |
|
|
I am trying to debug an issue I am seeing with our application (based on
EMF 2.6.1). We generate Java code from Ecore and then have config files
that dynamically add properties to EClasses at runtime.
What I am seeing is that new dynamic properties show up on the EClasses
but are not visible on derived classes (using getEAllStructureFeatures).
E.g. Derived -> MyClass
package mypackage;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.EcorePackage;
public class Main {
public static void main( String[] args ) {
IlrMypackagePackage pkg = IlrMypackagePackage.eINSTANCE;
EClass clazz = pkg.getMyClass();
EcorePackage theCorePackage = EcorePackage.eINSTANCE;
EcoreFactory theCoreFactory = EcoreFactory.eINSTANCE;
EAttribute bookStoreOwner = theCoreFactory.createEAttribute();
bookStoreOwner.setName("owner");
bookStoreOwner.setEType(theCorePackage.getEString());
clazz.getEStructuralFeatures().add(bookStoreOwner);
dumpEClass(clazz);
EClass derivedClazz = pkg.getDerived();
dumpEClass(derivedClazz);
}
private static void dumpEClass( EClass clazz ) {
System.out.println( "======" );
System.out.println( clazz.getName() );
EList<EStructuralFeature> list = clazz.getEAllStructuralFeatures();
for (EStructuralFeature eStructuralFeature : list) {
System.out.println( " " + eStructuralFeature.getName() );
}
System.out.println( "======" );
}
}
private static void dumpEClass( EClass clazz ) {
System.out.println( "======" );
System.out.println( clazz.getName() );
EList<EStructuralFeature> list = clazz.getEAllStructuralFeatures();
for (EStructuralFeature eStructuralFeature : list) {
System.out.println( " " + eStructuralFeature.getName() );
}
System.out.println( "======" );
}
Output:
======
MyClass
secondClass
Name
owner
======
======
Derived
secondClass
Name
======
Anyone have any ideas?
Thanks,
Dan
|
|
|
Powered by
FUDForum. Page generated in 0.02883 seconds