Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF serialization as .java file would give refactoring support....
EMF serialization as .java file would give refactoring support.... [message #430133] Tue, 12 May 2009 02:03 Go to next message
Michael Scharf is currently offline Michael ScharfFriend
Messages: 301
Registered: July 2009
Senior Member
Hi,

one of the annoying things of EMF is schema evolution:
With generated code, the trick is to first refactor (e.g
rename) in Java and then ecore and regenerate. That works
great for the code but not for any existing XMI file.
Because the XMI gets not refactored. I hate this!
I use EMF a lot to explore ideas and solutions. And I
often create 'sample' model data. If there would be a
".java" serialization, that is the
serialization would look like this:

PurchaseOrder aPurchaseOrder =
POFactory.eINSTANCE.createPurchaseOrder();
aPurchaseOrder.setBillTo("123 Maple Street");

Item aItem = POFactory.eINSTANCE.createItem();
aItem.setProductName("Apples");
aItem.setQuantity(12);
aItem.setPrice(0.50);

aPurchaseOrder.getItems().add(aItem);

If I would rename PurchaseOrder to Order and
setProductName to setProductId, I could do this
by refactoring and my serialized test models
would also be refactored....

Another advantage would be that you could use the
EMF tooling to create some model and use it directly in
your code without having to load an xmi file....

Has anybody tried this aproach?

Michael
--
Michael Scharf
Wind River Systems GmbH
http://www.WindRiver.com
http://MichaelScharf.blogspot.com/
Re: EMF serialization as .java file would give refactoring support.... [message #430134 is a reply to message #430133] Tue, 12 May 2009 02:10 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Michael,

Comments below.

Michael Scharf wrote:
> Hi,
>
> one of the annoying things of EMF is schema evolution:
> With generated code, the trick is to first refactor (e.g
> rename) in Java and then ecore and regenerate. That works
> great for the code but not for any existing XMI file.
> Because the XMI gets not refactored. I hate this!
> I use EMF a lot to explore ideas and solutions. And I
> often create 'sample' model data. If there would be a
> ".java" serialization, that is the
> serialization would look like this:
>
> PurchaseOrder aPurchaseOrder =
> POFactory.eINSTANCE.createPurchaseOrder();
> aPurchaseOrder.setBillTo("123 Maple Street");
>
> Item aItem = POFactory.eINSTANCE.createItem();
> aItem.setProductName("Apples");
> aItem.setQuantity(12);
> aItem.setPrice(0.50);
>
> aPurchaseOrder.getItems().add(aItem);
>
> If I would rename PurchaseOrder to Order and
> setProductName to setProductId, I could do this
> by refactoring and my serialized test models
> would also be refactored....
Have seen this http://www.eclipse.org/proposals/edapt/
>
> Another advantage would be that you could use the
> EMF tooling to create some model and use it directly in
> your code without having to load an xmi file....
>
> Has anybody tried this aproach?
Something to generate a Java "literal" would be interesting too. I've
not seen that...
>
> Michael


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EMF serialization as .java file would give refactoring support.... [message #430135 is a reply to message #430134] Tue, 12 May 2009 04:22 Go to previous messageGo to next message
Michael Scharf is currently offline Michael ScharfFriend
Messages: 301
Registered: July 2009
Senior Member
>> Has anybody tried this aproach?
> Something to generate a Java "literal" would be interesting too. I've
> not seen that...

hmm... well then I have to think about this.
Some years ago I created a little builder/parser
framework to read some legacy formats into EMF.

Is there a builder framework for EMF that I
could use to load the data?

And is there a serialization framework?

Michael
--
Michael Scharf
Wind River Systems GmbH
http://www.WindRiver.com
http://MichaelScharf.blogspot.com/
Re: EMF serialization as .java file would give refactoring support.... [message #430136 is a reply to message #430135] Tue, 12 May 2009 04:48 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Michael,

Comments below.

Michael Scharf wrote:
>>> Has anybody tried this aproach?
>> Something to generate a Java "literal" would be interesting too.
>> I've not seen that...
>
> hmm... well then I have to think about this.
> Some years ago I created a little builder/parser
> framework to read some legacy formats into EMF.
>
> Is there a builder framework for EMF that I
> could use to load the data?
I'm not sure what you mean by that. There are things like Ecore to
Ecore mappings to migrate from one version of a model to another.
>
> And is there a serialization framework?
There's all the XMI stuff. And of course ResourceImpl has doLoad and
doSave methods for hooking in alternative serialization scheme, like
BinaryResourceImpl does....
>
> Michael


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Re: [Teneo] Error on session.merge() - EMFInstantiator trying to create instance of abstract class?
Next Topic:net4j
Goto Forum:
  


Current Time: Thu Apr 25 01:45:12 GMT 2024

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

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

Back to the top