Home » Modeling » Modeling (top-level project) » Java Ecore metamodel and M2T Template
| | |
Re: Java Ecore metamodel and M2T Template [message #383946 is a reply to message #383943] |
Thu, 02 April 2009 13:09   |
Ed Merks Messages: 32836 Registered: July 2009 |
Senior Member |
|
|
Ersin,
Comments below.
Ersin ER wrote:
> Ed Merks wrote:
>> Ersin,
>>
>> The Java Ecore model from WTP was provided by VE I believe. It's
>> designed purely around reflection, i.e., building a model that
>> extends Ecore by reflecting on Java beans. There's also an example
>> EMF Java model in the EMF examples (in the SDK). It provides a model
>> that doesn't extend Ecore and supports building that an instance from
>> Java source. It does not support saving back to Java source.
>
> I just saw the example from EMF.
>
>> It seems a little funny to want to generate Java from a Java model.
>> If you already have the Java, why would you need to generate
>> anything, you'd just save the instance as a .java file...
>
> What do you mean by saving the instance as .java file? If I have an
> ecore file which is an xmi serialization of a Java model then it's
> clearly not a Java source file. Do I miss anything here?
Yes, I'd not expect to serialize a Java model as XMI. Java has a well
established exchange syntax already. The example EMF Java model
literally reads/loads a .java file and if it supported save, which it
doesn't, would write back to that same file using proper Java syntax...
>
> Thanks.
>
>>
>> Ersin ER wrote:
>>> Hi all,
>>>
>>> Although I know that WTP has some sort of Java Ecore metamodel, I
>>> cannot find it. Any reference is welcome. Another question is
>>> whether there any ready XPand or MTL templates for generating Java
>>> source code from the Java Ecore metamodel?
>>>
>>> Thanks.
>>>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Java Ecore metamodel and M2T Template [message #383947 is a reply to message #383946] |
Thu, 02 April 2009 13:19   |
Ersin ER Messages: 34 Registered: July 2009 |
Member |
|
|
Ed Merks wrote:
> Ersin,
>
> Comments below.
>
> Ersin ER wrote:
>> Ed Merks wrote:
>>> Ersin,
>>>
>>> The Java Ecore model from WTP was provided by VE I believe. It's
>>> designed purely around reflection, i.e., building a model that
>>> extends Ecore by reflecting on Java beans. There's also an example
>>> EMF Java model in the EMF examples (in the SDK). It provides a model
>>> that doesn't extend Ecore and supports building that an instance from
>>> Java source. It does not support saving back to Java source.
>>
>> I just saw the example from EMF.
>>
>>> It seems a little funny to want to generate Java from a Java model.
>>> If you already have the Java, why would you need to generate
>>> anything, you'd just save the instance as a .java file...
In fact Gronback's book gave the idea of generating Java code from a
model. To cite the introduction of section 7.3 of the book:
"7.3. Generating Java
As we've mentioned previously, you must consider at least two
possibilities when generating Java, or any programming language, from
models. The first is to use M2M from a source model into a Java model,
followed by Java generation using dedicated templates. The alternative
is to pass the source model to a set of templates designed to output
Java code. In the former, the logical mapping from one model to the
other takes place in the mappings of QVT; in the latter, the logic
resides in Xpand and Xtend code throughout the templates and extension
files. Sometimes one approach is superior to the other; as with the two
following examples, both are feasible when transforming our
Domain-Neutral Component (DNC) models to Java Persistence API (JPA) code."
As I see now, the book also provides an XPand template to generate Java
source from JEM.
Thanks for your responses.
>> What do you mean by saving the instance as .java file? If I have an
>> ecore file which is an xmi serialization of a Java model then it's
>> clearly not a Java source file. Do I miss anything here?
> Yes, I'd not expect to serialize a Java model as XMI. Java has a well
> established exchange syntax already. The example EMF Java model
> literally reads/loads a .java file and if it supported save, which it
> doesn't, would write back to that same file using proper Java syntax...
>>
>> Thanks.
>>
>>>
>>> Ersin ER wrote:
>>>> Hi all,
>>>>
>>>> Although I know that WTP has some sort of Java Ecore metamodel, I
>>>> cannot find it. Any reference is welcome. Another question is
>>>> whether there any ready XPand or MTL templates for generating Java
>>>> source code from the Java Ecore metamodel?
>>>>
>>>> Thanks.
>>>>
>>
|
|
|
Re: Java Ecore metamodel and M2T Template [message #383950 is a reply to message #383947] |
Thu, 02 April 2009 13:33   |
Ed Merks Messages: 32836 Registered: July 2009 |
Senior Member |
|
|
Ersin,
Comments below.
Ersin ER wrote:
> Ed Merks wrote:
>> Ersin,
>>
>> Comments below.
>>
>> Ersin ER wrote:
>>> Ed Merks wrote:
>>>> Ersin,
>>>>
>>>> The Java Ecore model from WTP was provided by VE I believe. It's
>>>> designed purely around reflection, i.e., building a model that
>>>> extends Ecore by reflecting on Java beans. There's also an example
>>>> EMF Java model in the EMF examples (in the SDK). It provides a
>>>> model that doesn't extend Ecore and supports building that an
>>>> instance from Java source. It does not support saving back to Java
>>>> source.
>>>
>>> I just saw the example from EMF.
>>>
>>>> It seems a little funny to want to generate Java from a Java
>>>> model. If you already have the Java, why would you need to
>>>> generate anything, you'd just save the instance as a .java file...
>
> In fact Gronback's book gave the idea of generating Java code from a
> model. To cite the introduction of section 7.3 of the book:
>
> "7.3. Generating Java
>
> As we've mentioned previously, you must consider at least two
> possibilities when generating Java, or any programming language, from
> models. The first is to use M2M from a source model into a Java model,
> followed by Java generation using dedicated templates.
It's a little bit like using templates to generate XML from DOM though.
After all, you can simply serialize DOM to XML. Of course when the
Java model doesn't support Java serialization, which the JEM model does
not, then templates make good sense.
> The alternative is to pass the source model to a set of templates
> designed to output Java code. In the former, the logical mapping from
> one model to the other takes place in the mappings of QVT; in the
> latter, the logic resides in Xpand and Xtend code throughout the
> templates and extension files. Sometimes one approach is superior to
> the other; as with the two following examples, both are feasible when
> transforming our Domain-Neutral Component (DNC) models to Java
> Persistence API (JPA) code."
>
> As I see now, the book also provides an XPand template to generate
> Java source from JEM.
:-)
>
> Thanks for your responses.
>
>>> What do you mean by saving the instance as .java file? If I have an
>>> ecore file which is an xmi serialization of a Java model then it's
>>> clearly not a Java source file. Do I miss anything here?
>> Yes, I'd not expect to serialize a Java model as XMI. Java has a
>> well established exchange syntax already. The example EMF Java
>> model literally reads/loads a .java file and if it supported save,
>> which it doesn't, would write back to that same file using proper
>> Java syntax...
>>>
>>> Thanks.
>>>
>>>>
>>>> Ersin ER wrote:
>>>>> Hi all,
>>>>>
>>>>> Although I know that WTP has some sort of Java Ecore metamodel, I
>>>>> cannot find it. Any reference is welcome. Another question is
>>>>> whether there any ready XPand or MTL templates for generating Java
>>>>> source code from the Java Ecore metamodel?
>>>>>
>>>>> Thanks.
>>>>>
>>>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | | | | | | | |
Re: Java Ecore metamodel and M2T Template [message #384276 is a reply to message #383940] |
Thu, 09 April 2009 03:18   |
Miles Parker Messages: 1341 Registered: July 2009 |
Senior Member |
|
|
On 2009-04-02 05:21:19 -0700, Ed Merks <Ed.Merks@gmail.com> said:
> Ersin,
>
> The Java Ecore model from WTP was provided by VE I believe. It's
> designed purely around reflection, i.e., building a model that extends
> Ecore by reflecting on Java beans. There's also an example EMF Java
> model in the EMF examples (in the SDK). It provides a model that
> doesn't extend Ecore and supports building that an instance from Java
> source. It does not support saving back to Java source.
>
> It seems a little funny to want to generate Java from a Java model. If
> you already have the Java, why would you need to generate anything,
> you'd just save the instance as a .java file...
>
On the other hand, the example Java model is super-useful for the
inverse. I use it to load java files -- a really simple way to get an
easily tourable Java strucutre. Users can then select Java classes and
they are transformed this into meta-objects within my target ecore
meta-model, and then I can generate code from *that*. :)
BTW, is org.eclipse.emf.java provided as part of any update site
feature? I haven't been able to find it and end up having to build and
include a copy on my own update site.
|
|
|
Re: Java Ecore metamodel and M2T Template [message #384277 is a reply to message #384276] |
Thu, 09 April 2009 12:27   |
Ed Merks Messages: 32836 Registered: July 2009 |
Senior Member |
|
|
Miles,
No, it's an example so it's only in the SDK and only as something you
unzip into your workspace, not as a functional installed plugin. Most
people would be disturbed by the extra "Open With" editor contribution
for *.java files.
Miles Parker wrote:
> On 2009-04-02 05:21:19 -0700, Ed Merks <Ed.Merks@gmail.com> said:
>
>> Ersin,
>>
>> The Java Ecore model from WTP was provided by VE I believe. It's
>> designed purely around reflection, i.e., building a model that
>> extends Ecore by reflecting on Java beans. There's also an example
>> EMF Java model in the EMF examples (in the SDK). It provides a model
>> that doesn't extend Ecore and supports building that an instance from
>> Java source. It does not support saving back to Java source.
>>
>> It seems a little funny to want to generate Java from a Java model.
>> If you already have the Java, why would you need to generate
>> anything, you'd just save the instance as a .java file...
>>
>
> On the other hand, the example Java model is super-useful for the
> inverse. I use it to load java files -- a really simple way to get an
> easily tourable Java strucutre. Users can then select Java classes and
> they are transformed this into meta-objects within my target ecore
> meta-model, and then I can generate code from *that*. :)
>
> BTW, is org.eclipse.emf.java provided as part of any update site
> feature? I haven't been able to find it and end up having to build and
> include a copy on my own update site.
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Java Ecore metamodel and M2T Template [message #384279 is a reply to message #384277] |
Thu, 09 April 2009 17:34   |
Miles Parker Messages: 1341 Registered: July 2009 |
Senior Member |
|
|
Good point... since I don't include ..edit or ..editor I don't see that issue.
On 2009-04-09 05:27:46 -0700, Ed Merks <Ed.Merks@gmail.com> said:
> Miles,
>
> No, it's an example so it's only in the SDK and only as something you
> unzip into your workspace, not as a functional installed plugin. Most
> people would be disturbed by the extra "Open With" editor contribution
> for *.java files.
>
>
>
> Miles Parker wrote:
>> On 2009-04-02 05:21:19 -0700, Ed Merks <Ed.Merks@gmail.com> said:
>>
>>> Ersin,
>>>
>>> The Java Ecore model from WTP was provided by VE I believe. It's
>>> designed purely around reflection, i.e., building a model that extends
>>> Ecore by reflecting on Java beans. There's also an example EMF Java
>>> model in the EMF examples (in the SDK). It provides a model that
>>> doesn't extend Ecore and supports building that an instance from Java
>>> source. It does not support saving back to Java source.
>>>
>>> It seems a little funny to want to generate Java from a Java model. If
>>> you already have the Java, why would you need to generate anything,
>>> you'd just save the instance as a .java file...
>>>
>>
>> On the other hand, the example Java model is super-useful for the
>> inverse. I use it to load java files -- a really simple way to get an
>> easily tourable Java strucutre. Users can then select Java classes and
>> they are transformed this into meta-objects within my target ecore
>> meta-model, and then I can generate code from *that*. :)
>>
>> BTW, is org.eclipse.emf.java provided as part of any update site
>> feature? I haven't been able to find it and end up having to build and
>> include a copy on my own update site.
|
|
| |
Re: Java Ecore metamodel and M2T Template [message #384426 is a reply to message #384425] |
Fri, 15 May 2009 17:37   |
|
Michael,
It may be inadequate or mentioned already but recently I noticed that
the MoDisco project provides a Java syntax model. I never played with it
but you might want to look at it.
Cheers
/Eike
----
http://thegordian.blogspot.com
Michael Shtelma schrieb:
> Hello,
>
>> I am interested in having EMF model of Java, did not find appropriate
>> so I use JDT and Xtend to parse Java. I did not like the Ecore example.
>
> I am also interested in instantiating Java MM using xTend or ATL and
> then generating java code. I have seen all the MM that was mentioned
> here, but can I generate Java code from them? I mean code which
> contains logic, like loops, ifs, etc.
> I was also thinking about registering Eclipse JDT beans as Java MM in
> oAW and instantiating using xTend....but it would be better to have
> normal ecore java which can be "serialized" to simple java code..
>
> Best regards,
> Michael Shtelma
>
>
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: Java Ecore metamodel and M2T Template [message #384427 is a reply to message #384425] |
Fri, 15 May 2009 23:44   |
Krzysztof Kowalczyk Messages: 113 Registered: July 2009 |
Senior Member |
|
|
Michael Shtelma pisze:
> I am also interested in instantiating Java MM using xTend or ATL and
> then generating java code. I have seen all the MM that was mentioned
> here, but can I generate Java code from them? I mean code which contains
> logic, like loops, ifs, etc.
I switched to http://www.eclipse.org/gmt/modisco/infrastructure/J2SE5/
it is the best option right know.
It correspond to resolved AST, so it knows what is pointed by given
names and you can generate full Java code from it. I already have Xpand
templates that generate Java code (~300 LOC, but without generics and
comments as I don't need them yet). I use it to refactor and modernize
projects.
I had to remove ATL dependencies from J2SE5 discoverer and I generate
ecore model for given project by hand, but you can create workflow
component or Xtend function for that.
> I was also thinking about registering Eclipse JDT beans as Java MM in
> oAW and instantiating using xTend....but it would be better to have
> normal ecore java which can be "serialized" to simple java code..
Java MM works quite well with IJavaModel, but it is not convenient for
AST and bindings.
Regards,
Krzysztof Kowalczyk
|
|
| | | |
Re: Java Ecore metamodel and M2T Template [message #384693 is a reply to message #384691] |
Tue, 19 May 2009 09:52   |
Michael Shtelma Messages: 10 Registered: July 2009 |
Junior Member |
|
|
Krzysztof Kowalczyk wrote:
> There is no Java generation provided yet, as I wrote before that I have
> done it myself in my use case. This project generate normal Ecore file
> so it have no synchronization with Java source.
> I don't know your requirements, why do you need model in sync? What do
> you want to accomplish?
> Regards,
> Krzysztof Kowalczyk
Sorry, I have not understood you, I thought that was previous version.
Regarding my requirements, I have to generate Java code from the model, in
other words to instantiate some model and generate corresponding Java
code. As far as I understand, it is possible to do this by instantiating
Eclipse JDT beans.
I am also investigating JEM (part of the Eclipse VE). As far as I
understand, it has needed features.
|
|
| |
Re: Java Ecore metamodel and M2T Template [message #499038 is a reply to message #496783] |
Thu, 19 November 2009 15:42   |
Krzysztof Kowalczyk Messages: 113 Registered: July 2009 |
Senior Member |
|
|
Jan,
Sorry for late reply, I was abroad.
I've added MoDisco newsgroup to the discussion. Maybe they are interested.
> Krzysztof,
>
> I more or less dived into the same "adventure" as you and the others in
> this thread. I have the four solutions on my investigation agenda which
> were mentioned already, the EMF example, JEM, MoDisc and oAW aka
> Xtext/Xtend/Xpand
>
> JEM seems to be outdated and out of the game from the beginning. I've
> started with the EMF example and MoDisc by now. The first one does not
> support serialization but seems to be fine for my purpose already since
> I do only need structure information for time being.
For know I am using MoDisco J2SE5 metamodel/discoverer with small
changes (I have removed ATL dependencies, as I don't use J2SE5 -> KDM ->
UML, nor ATL).
MoDisco have a bit newer (and as they claim better) model/discoverer
http://wiki.eclipse.org/MoDisco/Java , thus I will probably move to it
one day. The metamodel is not much different, so it should be easy.
> However, serialization will be quickly become an issue. You mentioned
> that you did wrote some templates and I'm not quite sure for which of
> the technologies you actually did that and (more important) whether you
> could imagine to share your results with us ;-)
I have working but incomplete templates in Eclipse M2T Xpand for
generating Java code from J2SE5 metamodel. They are not "production
quality". As I said before they do not handle comments, generics and
some basic constructs are missing. It is possible that they have some
errors, as they was not tested much. Nevertheless they works for me ;)
I can share them, preferably as open source contribution.
But, AFAIK MoDisco plans to develop some kind of serialization for Java
model. I am not sure will it be Java or Acceleo based serialization though.
> I'm also wondering whether there is any attempt to further develop the
> EMF example and add serialization. The project seems to be still alive
> at least (see comments from Marcelo in another thread at
> http://www.eclipse.org/forums/index.php?t=msg&goto=41414 8&S=bc1ad57bb4e7b26aa4a584e876ec7c7e)
I don't know that, you can ask on EMF forum.
Regards,
Krzysztof Kowalczyk
|
|
|
Re: Java Ecore metamodel and M2T Template [message #499190 is a reply to message #499038] |
Fri, 20 November 2009 10:51   |
Hugo Bruneliere Messages: 674 Registered: July 2009 |
Senior Member |
|
|
Hi Krzysztof,
Krzysztof Kowalczyk a écrit :
> Jan,
>
> Sorry for late reply, I was abroad.
> I've added MoDisco newsgroup to the discussion. Maybe they are interested.
>
>> Krzysztof,
>>
>> I more or less dived into the same "adventure" as you and the others
>> in this thread. I have the four solutions on my investigation agenda
>> which were mentioned already, the EMF example, JEM, MoDisc and oAW aka
>> Xtext/Xtend/Xpand
>>
>> JEM seems to be outdated and out of the game from the beginning. I've
>> started with the EMF example and MoDisc by now. The first one does not
>> support serialization but seems to be fine for my purpose already
>> since I do only need structure information for time being.
>
> For know I am using MoDisco J2SE5 metamodel/discoverer with small
> changes (I have removed ATL dependencies, as I don't use J2SE5 -> KDM ->
> UML, nor ATL).
>
> MoDisco have a bit newer (and as they claim better) model/discoverer
> http://wiki.eclipse.org/MoDisco/Java , thus I will probably move to it
> one day. The metamodel is not much different, so it should be easy.
Thanks for your interest in MoDisco.
Please, don't hesitate to provide your feedback on this new Java
metamodel implementation (and corresponding discoverer) ;-)
>
>> However, serialization will be quickly become an issue. You mentioned
>> that you did wrote some templates and I'm not quite sure for which of
>> the technologies you actually did that and (more important) whether
>> you could imagine to share your results with us ;-)
>
> I have working but incomplete templates in Eclipse M2T Xpand for
> generating Java code from J2SE5 metamodel. They are not "production
> quality". As I said before they do not handle comments, generics and
> some basic constructs are missing. It is possible that they have some
> errors, as they was not tested much. Nevertheless they works for me ;)
>
> I can share them, preferably as open source contribution.
> But, AFAIK MoDisco plans to develop some kind of serialization for Java
> model. I am not sure will it be Java or Acceleo based serialization though.
I would be great to have a standard serialization available for the Java
metamodel.
This is something we could discuss and your contribution could be
potentially made available via MoDisco at some point...
Best regards,
Hugo
>
>> I'm also wondering whether there is any attempt to further develop the
>> EMF example and add serialization. The project seems to be still alive
>> at least (see comments from Marcelo in another thread at
>> http://www.eclipse.org/forums/index.php?t=msg&goto=41414 8&S=bc1ad57bb4e7b26aa4a584e876ec7c7e)
>
>
> I don't know that, you can ask on EMF forum.
>
> Regards,
> Krzysztof Kowalczyk
--
-------------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (INRIA & EMN) - Room B206
Ecole des Mines de Nantes
4, rue Alfred Kastler
44307 Nantes Cedex 3 - France
Office: +33 (0)2 51 85 82 21
EMail: hugo.bruneliere@inria.fr
-------------------------------------------------
--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
|
|
| | |
Re: Java Ecore metamodel and M2T Template [message #499559 is a reply to message #499209] |
Mon, 23 November 2009 11:17  |
Hugo Bruneliere Messages: 674 Registered: July 2009 |
Senior Member |
|
|
Hi Krzysztof,
Krzysztof Kowalczyk a écrit :
> Jan Mauersberger:
>> I use the same meta model and also do not require KDM etc. However, I
>> wasn't aware the that the Java meta model is newer - I assumed the
>> other way around ;-)
>
> There are 3 models right know - JavaAST (the oldest one), J2SE5 and
> Java. The third one is recommended AFAIK.
You're right! These three metamodels correspond to the several
iterations that have been made in order to reach a fully satisfying
version, the Java metamodel being this final version.
>
>
> Hugo Bruneliere,
> It seems that MoDisco is devoted to ATL / Acceleo and my work is in
> Xpand / Xtend. Does it matter ?
>
It is true that our current works mainly use ATL as a M2M technology and
Acceleo as a M2T one.
However, MoDisco is not dependent from these technologies: it is
designed so that any kind of M2M or M2T technology may be used within a
given reverse-engineering process.
According to this, several drivers for such different technologies have
already been committed to the project.
Of course, we are open to potential contributors of other drivers for
other technologies ;-)
Best regards,
Hugo
> Regards,
> Krzysztof Kowalczyk
--
-------------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (INRIA & EMN) - Room B206
Ecole des Mines de Nantes
4, rue Alfred Kastler
44307 Nantes Cedex 3 - France
Office: +33 (0)2 51 85 82 21
EMail: hugo.bruneliere@inria.fr
-------------------------------------------------
--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
|
|
|
Re: Java Ecore metamodel and M2T Template [message #614955 is a reply to message #383937] |
Thu, 02 April 2009 12:21  |
Ed Merks Messages: 32836 Registered: July 2009 |
Senior Member |
|
|
Ersin,
The Java Ecore model from WTP was provided by VE I believe. It's
designed purely around reflection, i.e., building a model that extends
Ecore by reflecting on Java beans. There's also an example EMF Java
model in the EMF examples (in the SDK). It provides a model that
doesn't extend Ecore and supports building that an instance from Java
source. It does not support saving back to Java source.
It seems a little funny to want to generate Java from a Java model. If
you already have the Java, why would you need to generate anything,
you'd just save the instance as a .java file...
Ersin ER wrote:
> Hi all,
>
> Although I know that WTP has some sort of Java Ecore metamodel, I
> cannot find it. Any reference is welcome. Another question is whether
> there any ready XPand or MTL templates for generating Java source code
> from the Java Ecore metamodel?
>
> Thanks.
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: Java Ecore metamodel and M2T Template [message #614958 is a reply to message #383943] |
Thu, 02 April 2009 13:09  |
Ed Merks Messages: 32836 Registered: July 2009 |
Senior Member |
|
|
Ersin,
Comments below.
Ersin ER wrote:
> Ed Merks wrote:
>> Ersin,
>>
>> The Java Ecore model from WTP was provided by VE I believe. It's
>> designed purely around reflection, i.e., building a model that
>> extends Ecore by reflecting on Java beans. There's also an example
>> EMF Java model in the EMF examples (in the SDK). It provides a model
>> that doesn't extend Ecore and supports building that an instance from
>> Java source. It does not support saving back to Java source.
>
> I just saw the example from EMF.
>
>> It seems a little funny to want to generate Java from a Java model.
>> If you already have the Java, why would you need to generate
>> anything, you'd just save the instance as a .java file...
>
> What do you mean by saving the instance as .java file? If I have an
> ecore file which is an xmi serialization of a Java model then it's
> clearly not a Java source file. Do I miss anything here?
Yes, I'd not expect to serialize a Java model as XMI. Java has a well
established exchange syntax already. The example EMF Java model
literally reads/loads a .java file and if it supported save, which it
doesn't, would write back to that same file using proper Java syntax...
>
> Thanks.
>
>>
>> Ersin ER wrote:
>>> Hi all,
>>>
>>> Although I know that WTP has some sort of Java Ecore metamodel, I
>>> cannot find it. Any reference is welcome. Another question is
>>> whether there any ready XPand or MTL templates for generating Java
>>> source code from the Java Ecore metamodel?
>>>
>>> Thanks.
>>>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Java Ecore metamodel and M2T Template [message #614960 is a reply to message #383946] |
Thu, 02 April 2009 13:19  |
Ersin ER Messages: 34 Registered: July 2009 |
Member |
|
|
Ed Merks wrote:
> Ersin,
>
> Comments below.
>
> Ersin ER wrote:
>> Ed Merks wrote:
>>> Ersin,
>>>
>>> The Java Ecore model from WTP was provided by VE I believe. It's
>>> designed purely around reflection, i.e., building a model that
>>> extends Ecore by reflecting on Java beans. There's also an example
>>> EMF Java model in the EMF examples (in the SDK). It provides a model
>>> that doesn't extend Ecore and supports building that an instance from
>>> Java source. It does not support saving back to Java source.
>>
>> I just saw the example from EMF.
>>
>>> It seems a little funny to want to generate Java from a Java model.
>>> If you already have the Java, why would you need to generate
>>> anything, you'd just save the instance as a .java file...
In fact Gronback's book gave the idea of generating Java code from a
model. To cite the introduction of section 7.3 of the book:
"7.3. Generating Java
As we've mentioned previously, you must consider at least two
possibilities when generating Java, or any programming language, from
models. The first is to use M2M from a source model into a Java model,
followed by Java generation using dedicated templates. The alternative
is to pass the source model to a set of templates designed to output
Java code. In the former, the logical mapping from one model to the
other takes place in the mappings of QVT; in the latter, the logic
resides in Xpand and Xtend code throughout the templates and extension
files. Sometimes one approach is superior to the other; as with the two
following examples, both are feasible when transforming our
Domain-Neutral Component (DNC) models to Java Persistence API (JPA) code."
As I see now, the book also provides an XPand template to generate Java
source from JEM.
Thanks for your responses.
>> What do you mean by saving the instance as .java file? If I have an
>> ecore file which is an xmi serialization of a Java model then it's
>> clearly not a Java source file. Do I miss anything here?
> Yes, I'd not expect to serialize a Java model as XMI. Java has a well
> established exchange syntax already. The example EMF Java model
> literally reads/loads a .java file and if it supported save, which it
> doesn't, would write back to that same file using proper Java syntax...
>>
>> Thanks.
>>
>>>
>>> Ersin ER wrote:
>>>> Hi all,
>>>>
>>>> Although I know that WTP has some sort of Java Ecore metamodel, I
>>>> cannot find it. Any reference is welcome. Another question is
>>>> whether there any ready XPand or MTL templates for generating Java
>>>> source code from the Java Ecore metamodel?
>>>>
>>>> Thanks.
>>>>
>>
|
|
|
Re: Java Ecore metamodel and M2T Template [message #614962 is a reply to message #383947] |
Thu, 02 April 2009 13:33  |
Ed Merks Messages: 32836 Registered: July 2009 |
Senior Member |
|
|
Ersin,
Comments below.
Ersin ER wrote:
> Ed Merks wrote:
>> Ersin,
>>
>> Comments below.
>>
>> Ersin ER wrote:
>>> Ed Merks wrote:
>>>> Ersin,
>>>>
>>>> The Java Ecore model from WTP was provided by VE I believe. It's
>>>> designed purely around reflection, i.e., building a model that
>>>> extends Ecore by reflecting on Java beans. There's also an example
>>>> EMF Java model in the EMF examples (in the SDK). It provides a
>>>> model that doesn't extend Ecore and supports building that an
>>>> instance from Java source. It does not support saving back to Java
>>>> source.
>>>
>>> I just saw the example from EMF.
>>>
>>>> It seems a little funny to want to generate Java from a Java
>>>> model. If you already have the Java, why would you need to
>>>> generate anything, you'd just save the instance as a .java file...
>
> In fact Gronback's book gave the idea of generating Java code from a
> model. To cite the introduction of section 7.3 of the book:
>
> "7.3. Generating Java
>
> As we've mentioned previously, you must consider at least two
> possibilities when generating Java, or any programming language, from
> models. The first is to use M2M from a source model into a Java model,
> followed by Java generation using dedicated templates.
It's a little bit like using templates to generate XML from DOM though.
After all, you can simply serialize DOM to XML. Of course when the
Java model doesn't support Java serialization, which the JEM model does
not, then templates make good sense.
> The alternative is to pass the source model to a set of templates
> designed to output Java code. In the former, the logical mapping from
> one model to the other takes place in the mappings of QVT; in the
> latter, the logic resides in Xpand and Xtend code throughout the
> templates and extension files. Sometimes one approach is superior to
> the other; as with the two following examples, both are feasible when
> transforming our Domain-Neutral Component (DNC) models to Java
> Persistence API (JPA) code."
>
> As I see now, the book also provides an XPand template to generate
> Java source from JEM.
:-)
>
> Thanks for your responses.
>
>>> What do you mean by saving the instance as .java file? If I have an
>>> ecore file which is an xmi serialization of a Java model then it's
>>> clearly not a Java source file. Do I miss anything here?
>> Yes, I'd not expect to serialize a Java model as XMI. Java has a
>> well established exchange syntax already. The example EMF Java
>> model literally reads/loads a .java file and if it supported save,
>> which it doesn't, would write back to that same file using proper
>> Java syntax...
>>>
>>> Thanks.
>>>
>>>>
>>>> Ersin ER wrote:
>>>>> Hi all,
>>>>>
>>>>> Although I know that WTP has some sort of Java Ecore metamodel, I
>>>>> cannot find it. Any reference is welcome. Another question is
>>>>> whether there any ready XPand or MTL templates for generating Java
>>>>> source code from the Java Ecore metamodel?
>>>>>
>>>>> Thanks.
>>>>>
>>>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | | | | | | | |
Re: Java Ecore metamodel and M2T Template [message #615311 is a reply to message #383940] |
Thu, 09 April 2009 03:18  |
Miles Parker Messages: 1341 Registered: July 2009 |
Senior Member |
|
|
On 2009-04-02 05:21:19 -0700, Ed Merks <Ed.Merks@gmail.com> said:
> Ersin,
>
> The Java Ecore model from WTP was provided by VE I believe. It's
> designed purely around reflection, i.e., building a model that extends
> Ecore by reflecting on Java beans. There's also an example EMF Java
> model in the EMF examples (in the SDK). It provides a model that
> doesn't extend Ecore and supports building that an instance from Java
> source. It does not support saving back to Java source.
>
> It seems a little funny to want to generate Java from a Java model. If
> you already have the Java, why would you need to generate anything,
> you'd just save the instance as a .java file...
>
On the other hand, the example Java model is super-useful for the
inverse. I use it to load java files -- a really simple way to get an
easily tourable Java strucutre. Users can then select Java classes and
they are transformed this into meta-objects within my target ecore
meta-model, and then I can generate code from *that*. :)
BTW, is org.eclipse.emf.java provided as part of any update site
feature? I haven't been able to find it and end up having to build and
include a copy on my own update site.
|
|
|
Re: Java Ecore metamodel and M2T Template [message #615313 is a reply to message #384276] |
Thu, 09 April 2009 12:27  |
Ed Merks Messages: 32836 Registered: July 2009 |
Senior Member |
|
|
Miles,
No, it's an example so it's only in the SDK and only as something you
unzip into your workspace, not as a functional installed plugin. Most
people would be disturbed by the extra "Open With" editor contribution
for *.java files.
Miles Parker wrote:
> On 2009-04-02 05:21:19 -0700, Ed Merks <Ed.Merks@gmail.com> said:
>
>> Ersin,
>>
>> The Java Ecore model from WTP was provided by VE I believe. It's
>> designed purely around reflection, i.e., building a model that
>> extends Ecore by reflecting on Java beans. There's also an example
>> EMF Java model in the EMF examples (in the SDK). It provides a model
>> that doesn't extend Ecore and supports building that an instance from
>> Java source. It does not support saving back to Java source.
>>
>> It seems a little funny to want to generate Java from a Java model.
>> If you already have the Java, why would you need to generate
>> anything, you'd just save the instance as a .java file...
>>
>
> On the other hand, the example Java model is super-useful for the
> inverse. I use it to load java files -- a really simple way to get an
> easily tourable Java strucutre. Users can then select Java classes and
> they are transformed this into meta-objects within my target ecore
> meta-model, and then I can generate code from *that*. :)
>
> BTW, is org.eclipse.emf.java provided as part of any update site
> feature? I haven't been able to find it and end up having to build and
> include a copy on my own update site.
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Java Ecore metamodel and M2T Template [message #615316 is a reply to message #384277] |
Thu, 09 April 2009 17:34  |
Miles Parker Messages: 1341 Registered: July 2009 |
Senior Member |
|
|
Good point... since I don't include ..edit or ..editor I don't see that issue.
On 2009-04-09 05:27:46 -0700, Ed Merks <Ed.Merks@gmail.com> said:
> Miles,
>
> No, it's an example so it's only in the SDK and only as something you
> unzip into your workspace, not as a functional installed plugin. Most
> people would be disturbed by the extra "Open With" editor contribution
> for *.java files.
>
>
>
> Miles Parker wrote:
>> On 2009-04-02 05:21:19 -0700, Ed Merks <Ed.Merks@gmail.com> said:
>>
>>> Ersin,
>>>
>>> The Java Ecore model from WTP was provided by VE I believe. It's
>>> designed purely around reflection, i.e., building a model that extends
>>> Ecore by reflecting on Java beans. There's also an example EMF Java
>>> model in the EMF examples (in the SDK). It provides a model that
>>> doesn't extend Ecore and supports building that an instance from Java
>>> source. It does not support saving back to Java source.
>>>
>>> It seems a little funny to want to generate Java from a Java model. If
>>> you already have the Java, why would you need to generate anything,
>>> you'd just save the instance as a .java file...
>>>
>>
>> On the other hand, the example Java model is super-useful for the
>> inverse. I use it to load java files -- a really simple way to get an
>> easily tourable Java strucutre. Users can then select Java classes and
>> they are transformed this into meta-objects within my target ecore
>> meta-model, and then I can generate code from *that*. :)
>>
>> BTW, is org.eclipse.emf.java provided as part of any update site
>> feature? I haven't been able to find it and end up having to build and
>> include a copy on my own update site.
|
|
| |
Re: Java Ecore metamodel and M2T Template [message #615736 is a reply to message #384425] |
Fri, 15 May 2009 17:37  |
|
Michael,
It may be inadequate or mentioned already but recently I noticed that
the MoDisco project provides a Java syntax model. I never played with it
but you might want to look at it.
Cheers
/Eike
----
http://thegordian.blogspot.com
Michael Shtelma schrieb:
> Hello,
>
>> I am interested in having EMF model of Java, did not find appropriate
>> so I use JDT and Xtend to parse Java. I did not like the Ecore example.
>
> I am also interested in instantiating Java MM using xTend or ATL and
> then generating java code. I have seen all the MM that was mentioned
> here, but can I generate Java code from them? I mean code which
> contains logic, like loops, ifs, etc.
> I was also thinking about registering Eclipse JDT beans as Java MM in
> oAW and instantiating using xTend....but it would be better to have
> normal ecore java which can be "serialized" to simple java code..
>
> Best regards,
> Michael Shtelma
>
>
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: Java Ecore metamodel and M2T Template [message #615738 is a reply to message #384425] |
Fri, 15 May 2009 23:44  |
Krzysztof Kowalczyk Messages: 113 Registered: July 2009 |
Senior Member |
|
|
Michael Shtelma pisze:
> I am also interested in instantiating Java MM using xTend or ATL and
> then generating java code. I have seen all the MM that was mentioned
> here, but can I generate Java code from them? I mean code which contains
> logic, like loops, ifs, etc.
I switched to http://www.eclipse.org/gmt/modisco/infrastructure/J2SE5/
it is the best option right know.
It correspond to resolved AST, so it knows what is pointed by given
names and you can generate full Java code from it. I already have Xpand
templates that generate Java code (~300 LOC, but without generics and
comments as I don't need them yet). I use it to refactor and modernize
projects.
I had to remove ATL dependencies from J2SE5 discoverer and I generate
ecore model for given project by hand, but you can create workflow
component or Xtend function for that.
> I was also thinking about registering Eclipse JDT beans as Java MM in
> oAW and instantiating using xTend....but it would be better to have
> normal ecore java which can be "serialized" to simple java code..
Java MM works quite well with IJavaModel, but it is not convenient for
AST and bindings.
Regards,
Krzysztof Kowalczyk
|
|
| | | |
Re: Java Ecore metamodel and M2T Template [message #616456 is a reply to message #384691] |
Tue, 19 May 2009 09:52  |
Michael Shtelma Messages: 10 Registered: July 2009 |
Junior Member |
|
|
Krzysztof Kowalczyk wrote:
> There is no Java generation provided yet, as I wrote before that I have
> done it myself in my use case. This project generate normal Ecore file
> so it have no synchronization with Java source.
> I don't know your requirements, why do you need model in sync? What do
> you want to accomplish?
> Regards,
> Krzysztof Kowalczyk
Sorry, I have not understood you, I thought that was previous version.
Regarding my requirements, I have to generate Java code from the model, in
other words to instantiate some model and generate corresponding Java
code. As far as I understand, it is possible to do this by instantiating
Eclipse JDT beans.
I am also investigating JEM (part of the Eclipse VE). As far as I
understand, it has needed features.
|
|
| |
Re: Java Ecore metamodel and M2T Template [message #618492 is a reply to message #496783] |
Thu, 19 November 2009 15:42  |
Krzysztof Kowalczyk Messages: 113 Registered: July 2009 |
Senior Member |
|
|
Jan,
Sorry for late reply, I was abroad.
I've added MoDisco newsgroup to the discussion. Maybe they are interested.
> Krzysztof,
>
> I more or less dived into the same "adventure" as you and the others in
> this thread. I have the four solutions on my investigation agenda which
> were mentioned already, the EMF example, JEM, MoDisc and oAW aka
> Xtext/Xtend/Xpand
>
> JEM seems to be outdated and out of the game from the beginning. I've
> started with the EMF example and MoDisc by now. The first one does not
> support serialization but seems to be fine for my purpose already since
> I do only need structure information for time being.
For know I am using MoDisco J2SE5 metamodel/discoverer with small
changes (I have removed ATL dependencies, as I don't use J2SE5 -> KDM ->
UML, nor ATL).
MoDisco have a bit newer (and as they claim better) model/discoverer
http://wiki.eclipse.org/MoDisco/Java , thus I will probably move to it
one day. The metamodel is not much different, so it should be easy.
> However, serialization will be quickly become an issue. You mentioned
> that you did wrote some templates and I'm not quite sure for which of
> the technologies you actually did that and (more important) whether you
> could imagine to share your results with us ;-)
I have working but incomplete templates in Eclipse M2T Xpand for
generating Java code from J2SE5 metamodel. They are not "production
quality". As I said before they do not handle comments, generics and
some basic constructs are missing. It is possible that they have some
errors, as they was not tested much. Nevertheless they works for me ;)
I can share them, preferably as open source contribution.
But, AFAIK MoDisco plans to develop some kind of serialization for Java
model. I am not sure will it be Java or Acceleo based serialization though.
> I'm also wondering whether there is any attempt to further develop the
> EMF example and add serialization. The project seems to be still alive
> at least (see comments from Marcelo in another thread at
> http://www.eclipse.org/forums/index.php?t=msg&goto=41414 8&S=bc1ad57bb4e7b26aa4a584e876ec7c7e)
I don't know that, you can ask on EMF forum.
Regards,
Krzysztof Kowalczyk
|
|
|
Re: Java Ecore metamodel and M2T Template [message #618498 is a reply to message #499038] |
Fri, 20 November 2009 10:51  |
Hugo Bruneliere Messages: 674 Registered: July 2009 |
Senior Member |
|
|
Hi Krzysztof,
Krzysztof Kowalczyk a écrit :
> Jan,
>
> Sorry for late reply, I was abroad.
> I've added MoDisco newsgroup to the discussion. Maybe they are interested.
>
>> Krzysztof,
>>
>> I more or less dived into the same "adventure" as you and the others
>> in this thread. I have the four solutions on my investigation agenda
>> which were mentioned already, the EMF example, JEM, MoDisc and oAW aka
>> Xtext/Xtend/Xpand
>>
>> JEM seems to be outdated and out of the game from the beginning. I've
>> started with the EMF example and MoDisc by now. The first one does not
>> support serialization but seems to be fine for my purpose already
>> since I do only need structure information for time being.
>
> For know I am using MoDisco J2SE5 metamodel/discoverer with small
> changes (I have removed ATL dependencies, as I don't use J2SE5 -> KDM ->
> UML, nor ATL).
>
> MoDisco have a bit newer (and as they claim better) model/discoverer
> http://wiki.eclipse.org/MoDisco/Java , thus I will probably move to it
> one day. The metamodel is not much different, so it should be easy.
Thanks for your interest in MoDisco.
Please, don't hesitate to provide your feedback on this new Java
metamodel implementation (and corresponding discoverer) ;-)
>
>> However, serialization will be quickly become an issue. You mentioned
>> that you did wrote some templates and I'm not quite sure for which of
>> the technologies you actually did that and (more important) whether
>> you could imagine to share your results with us ;-)
>
> I have working but incomplete templates in Eclipse M2T Xpand for
> generating Java code from J2SE5 metamodel. They are not "production
> quality". As I said before they do not handle comments, generics and
> some basic constructs are missing. It is possible that they have some
> errors, as they was not tested much. Nevertheless they works for me ;)
>
> I can share them, preferably as open source contribution.
> But, AFAIK MoDisco plans to develop some kind of serialization for Java
> model. I am not sure will it be Java or Acceleo based serialization though.
I would be great to have a standard serialization available for the Java
metamodel.
This is something we could discuss and your contribution could be
potentially made available via MoDisco at some point...
Best regards,
Hugo
>
>> I'm also wondering whether there is any attempt to further develop the
>> EMF example and add serialization. The project seems to be still alive
>> at least (see comments from Marcelo in another thread at
>> http://www.eclipse.org/forums/index.php?t=msg&goto=41414 8&S=bc1ad57bb4e7b26aa4a584e876ec7c7e)
>
>
> I don't know that, you can ask on EMF forum.
>
> Regards,
> Krzysztof Kowalczyk
--
-------------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (INRIA & EMN) - Room B206
Ecole des Mines de Nantes
4, rue Alfred Kastler
44307 Nantes Cedex 3 - France
Office: +33 (0)2 51 85 82 21
EMail: hugo.bruneliere@inria.fr
-------------------------------------------------
--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
|
|
| | |
Re: Java Ecore metamodel and M2T Template [message #618576 is a reply to message #499209] |
Mon, 23 November 2009 11:17  |
Hugo Bruneliere Messages: 674 Registered: July 2009 |
Senior Member |
|
|
Hi Krzysztof,
Krzysztof Kowalczyk a écrit :
> Jan Mauersberger:
>> I use the same meta model and also do not require KDM etc. However, I
>> wasn't aware the that the Java meta model is newer - I assumed the
>> other way around ;-)
>
> There are 3 models right know - JavaAST (the oldest one), J2SE5 and
> Java. The third one is recommended AFAIK.
You're right! These three metamodels correspond to the several
iterations that have been made in order to reach a fully satisfying
version, the Java metamodel being this final version.
>
>
> Hugo Bruneliere,
> It seems that MoDisco is devoted to ATL / Acceleo and my work is in
> Xpand / Xtend. Does it matter ?
>
It is true that our current works mainly use ATL as a M2M technology and
Acceleo as a M2T one.
However, MoDisco is not dependent from these technologies: it is
designed so that any kind of M2M or M2T technology may be used within a
given reverse-engineering process.
According to this, several drivers for such different technologies have
already been committed to the project.
Of course, we are open to potential contributors of other drivers for
other technologies ;-)
Best regards,
Hugo
> Regards,
> Krzysztof Kowalczyk
--
-------------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (INRIA & EMN) - Room B206
Ecole des Mines de Nantes
4, rue Alfred Kastler
44307 Nantes Cedex 3 - France
Office: +33 (0)2 51 85 82 21
EMail: hugo.bruneliere@inria.fr
-------------------------------------------------
--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
|
|
|
Goto Forum:
Current Time: Thu Jun 08 23:22:42 GMT 2023
Powered by FUDForum. Page generated in 0.05989 seconds
|