Home » Modeling » EMF » Reflective Java code generator for instances ?
Reflective Java code generator for instances ? [message #539401] |
Thu, 10 June 2010 15:25 |
Cedric Brun Messages: 431 Registered: July 2009 |
Senior Member |
|
|
Hi all,
I'm wondering, because it looks like a pretty basic need, if anybody out
there already wrote a code generator generating, from any EMF based model,
the sequence of Java statements needed to instantiate it ?
It would be usefull for instance to capture model instances for unit
testing, the unit test is then independant of the launching mode (plugin or
not) and breaking the API compatiblity breaks the java compilation..
Anybody heard something about such a thing ?
Cheers,
Cédric
http://cedric.brun.io news and articles on eclipse and eclipse modeling.
|
|
|
Re: Reflective Java code generator for instances ? [message #539476 is a reply to message #539401] |
Thu, 10 June 2010 21:41 |
Jonas Helming Messages: 699 Registered: July 2009 |
Senior Member |
|
|
Hi,
did I get you write, that you need code to instanciate a arbitrary model
completly for testing issues? We have a random generator with a
configurable depth and reference level.
But I am not sure if that what you requested ;-)
Cheers
Jonas
Cédric Brun wrote:
> Hi all,
>
> I'm wondering, because it looks like a pretty basic need, if anybody out
> there already wrote a code generator generating, from any EMF based model,
> the sequence of Java statements needed to instantiate it ?
>
> It would be usefull for instance to capture model instances for unit
> testing, the unit test is then independant of the launching mode (plugin or
> not) and breaking the API compatiblity breaks the java compilation..
>
> Anybody heard something about such a thing ?
>
> Cheers,
>
> Cédric
>
|
|
|
Re: Reflective Java code generator for instances ? [message #539645 is a reply to message #539476] |
Fri, 11 June 2010 15:26 |
Cedric Brun Messages: 431 Registered: July 2009 |
Senior Member |
|
|
That's quite tricky to explain though not so complex todo , I'd like to
generate the java code needed to instanciate instance of a model from a
model.
Basically turning this :
<eClassifiers name="a" />
[...]
into this
EClass a = EcoreFactory.eINSTANCE.createEClass();
a.setName("a");
[...]
If nothing is available I'll write one and share it ;)
Jonas wrote:
> Hi,
> did I get you write, that you need code to instanciate a arbitrary model
> completly for testing issues? We have a random generator with a
> configurable depth and reference level.
> But I am not sure if that what you requested ;-)
> Cheers
> Jonas
>
> Cédric Brun wrote:
>> Hi all,
>>
>> I'm wondering, because it looks like a pretty basic need, if anybody out
>> there already wrote a code generator generating, from any EMF based
>> model, the sequence of Java statements needed to instantiate it ?
>>
>> It would be usefull for instance to capture model instances for unit
>> testing, the unit test is then independant of the launching mode (plugin
>> or not) and breaking the API compatiblity breaks the java compilation..
>>
>> Anybody heard something about such a thing ?
>>
>> Cheers,
>>
>> Cédric
>>
http://cedric.brun.io news and articles on eclipse and eclipse modeling.
|
|
|
Re: Reflective Java code generator for instances ? [message #539646 is a reply to message #539645] |
Fri, 11 June 2010 15:34 |
Ed Merks Messages: 33113 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------020304020907090009060207
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Cédric,
Long ago I thought about writing such a thing but I don't believe anyone
else has done it.
Cédric Brun wrote:
> That's quite tricky to explain though not so complex todo , I'd like to
> generate the java code needed to instanciate instance of a model from a
> model.
> Basically turning this :
>
> <eClassifiers name="a" />
> [...]
>
> into this
>
>
> EClass a = EcoreFactory.eINSTANCE.createEClass();
> a.setName("a");
> [...]
>
>
> If nothing is available I'll write one and share it ;)
>
>
> Jonas wrote:
>
>
>> Hi,
>> did I get you write, that you need code to instanciate a arbitrary model
>> completly for testing issues? We have a random generator with a
>> configurable depth and reference level.
>> But I am not sure if that what you requested ;-)
>> Cheers
>> Jonas
>>
>> Cédric Brun wrote:
>>
>>> Hi all,
>>>
>>> I'm wondering, because it looks like a pretty basic need, if anybody out
>>> there already wrote a code generator generating, from any EMF based
>>> model, the sequence of Java statements needed to instantiate it ?
>>>
>>> It would be usefull for instance to capture model instances for unit
>>> testing, the unit test is then independant of the launching mode (plugin
>>> or not) and breaking the API compatiblity breaks the java compilation..
>>>
>>> Anybody heard something about such a thing ?
>>>
>>> Cheers,
>>>
>>> Cédric
>>>
>>>
>
>
--------------020304020907090009060207
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Cédric,<br>
<br>
Long ago I thought about writing such a thing but I don't believe
anyone else has done it.<br>
<br>
<br>
Cédric Brun wrote:
<blockquote cite="mid:hutkel$kf3$1@build.eclipse.org" type="cite">
<pre wrap="">That's quite tricky to explain though not so complex todo , I'd like to
generate the java code needed to instanciate instance of a model from a
model.
Basically turning this :
<eClassifiers name="a" />
[...]
into this
EClass a = EcoreFactory.eINSTANCE.createEClass();
a.setName("a");
[...]
If nothing is available I'll write one and share it ;)
Jonas wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,
did I get you write, that you need code to instanciate a arbitrary model
completly for testing issues? We have a random generator with a
configurable depth and reference level.
But I am not sure if that what you requested ;-)
Cheers
Jonas
Cédric Brun wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi all,
I'm wondering, because it looks like a pretty basic need, if anybody out
there already wrote a code generator generating, from any EMF based
model, the sequence of Java statements needed to instantiate it ?
It would be usefull for instance to capture model instances for unit
testing, the unit test is then independant of the launching mode (plugin
or not) and breaking the API compatiblity breaks the java compilation..
Anybody heard something about such a thing ?
Cheers,
Cédric
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
</body>
</html>
--------------020304020907090009060207--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Reflective Java code generator for instances ? [message #539658 is a reply to message #539645] |
Fri, 11 June 2010 17:28 |
Alex Mising name Messages: 51 Registered: August 2009 |
Member |
|
|
> That's quite tricky to explain though not so complex todo , I'd like to
> generate the java code needed to instanciate instance of a model from a model.
Even though you are using Ecore itself as an example, you'd like to have this available for any EMF model (described in Ecore), not just Ecore model itself, right? (For Ecore itself, doesn't EMF generator do something very similar, for small enough models?)
The output artifact is expected to be Java code that builds the instance, correct?
As far as tooling, while this surely can be done in code, model-to-text (such as Acceleo) seems a perfect fit. Ecore-to-JavaCodeModel-to text is likely an overkill?
Alex
|
|
|
Re: Reflective Java code generator for instances ? [message #539888 is a reply to message #539658] |
Mon, 14 June 2010 08:20 |
Cedric Brun Messages: 431 Registered: July 2009 |
Senior Member |
|
|
Hi Alex,
You're right, for any kind of model, as an Acceleo commiter I'll work on it
and provide it back soon ;)
Cédric
Alex wrote:
>> That's quite tricky to explain though not so complex todo , I'd like to
>> generate the java code needed to instanciate instance of a model from a
>> model.
>
> Even though you are using Ecore itself as an example, you'd like to have
> this available for any EMF model (described in Ecore), not just Ecore
> model itself, right? (For Ecore itself, doesn't EMF generator do something
> very similar, for small enough models?)
>
> The output artifact is expected to be Java code that builds the instance,
> correct?
>
> As far as tooling, while this surely can be done in code, model-to-text
> (such as Acceleo) seems a perfect fit. Ecore-to-JavaCodeModel-to text is
> likely an overkill? ;)
>
> Alex
http://cedric.brun.io news and articles on eclipse and eclipse modeling.
|
|
|
Goto Forum:
Current Time: Fri Mar 29 10:44:54 GMT 2024
Powered by FUDForum. Page generated in 0.02905 seconds
|