Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Dynamic loading of Meta Model
Dynamic loading of Meta Model [message #1808243] Thu, 20 June 2019 08:59 Go to next message
Kai S. is currently offline Kai S.Friend
Messages: 20
Registered: June 2019
Junior Member
Hello everyone,

I somehow cannot seem to find a solution to what I am trying to do on my own, so I am sorry if this is somehow covered somehwere already:

I want to dynamically create a model instance based on an Ecore meta model I do not know yet at development time but only at runtime. So the user of my app shall be able to specify an Ecore meta model he created (how does he do that best? via a URI he declared while building the meta model?) and specify the info about how the concrete model instance shall look like. So I dynamically get the info about what classes shall get created and how the attributes of this class shall get set.

So I basically want to do something like this, without having the concrete factory at development time:
MyXYZFactory.eINSTANCE.createAtThisStateUnknownType().setSomeAttribute("User-specified-value");


So, I basically need something like this pseudo-code here:
EFactory factory = getFactoryFromEcoreURI(URI_TO_METAMODEL_AS_SPECIFIED_BY_USER_AT_RUNTIME);
eClass dynamicClass = factory.createEClass("user specified EClass-name of the meta model he built");
EStructuralFeature nameAttribute = dynamicClass.getEStructuralFeature("name");
if(nameAttribute instanceof EAttribute) dynamicClass.eSet(nameAttribute, "user_specified_value");


Can anyone help me out on how I actually do this?

Thank you very much!
Re: Dynamic loading of Meta Model [message #1808251 is a reply to message #1808243] Thu, 20 June 2019 10:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30681
Registered: July 2009
Senior Member
Here's a pretty old article:

https://www.ibm.com/developerworks/library/os-eclipse-dynamicemf/?ca=drs
Re: Dynamic loading of Meta Model [message #1808253 is a reply to message #1808251] Thu, 20 June 2019 13:04 Go to previous message
Kai S. is currently offline Kai S.Friend
Messages: 20
Registered: June 2019
Junior Member
This looks more like the dynamic creation of a meta model itself, not reading in an existing meta model dynamically and then acting upon it.

But I think from that site I got some other ideas and found this from some further research: http://www.voelter.de/data/blog/DynamicModelCreationTest.java.html

This looks like exactly what I am trying to achieve, so I will play a bit with it.

Thanks for your answer!
Previous Topic:Ecore validation
Next Topic:[GWT] Compilation Problems
Goto Forum:
  


Current Time: Thu Dec 05 21:47:02 GMT 2019

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

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

Back to the top