Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » UML2 to Java class without any ECore dependencies
UML2 to Java class without any ECore dependencies [message #58765] Sat, 21 March 2009 10:50 Go to next message
joel is currently offline joel
Messages: 17
Registered: July 2009
Junior Member
Hi all,

I'm trying to generate my Java domain class from my UML2 model. For that
purpose I did a class diagram using Eclipse UML2 plugin, I generated its
related EMF model and then loaded it into a genmodel, as given here:
http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.u ml2tools/msg00703.html

The problem is that each class are extending EObject, etc. As I understood
(I'm new to EMF), EMF seems to be a "model of a model" definition.
On my side, I only want to get my UML diagram as Java class without having
any EObject inheritence. Is there a way to simply achieve this ?

Thank you in advance.

Best regards,

Joël
Re: UML2 to Java class without any ECore dependencies [message #58791 is a reply to message #58765] Sat, 21 March 2009 11:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25747
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020901030204020309030402
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Jo
Re: UML2 to Java class without any ECore dependencies [message #58816 is a reply to message #58791] Sat, 21 March 2009 13:26 Go to previous messageGo to next message
joel is currently offline joel
Messages: 17
Registered: July 2009
Junior Member
Hello Ed,

Sorry for the cross post, it was a mistake from my side...

> I don't know of any projects at Eclipse that generate Java directly from
> UML2.

My issue is not really related to the "directly". I don't really care if I
need to go through EMF and then genmodel to get my Java source code. The
main problem is how the Java code is generated (with dependencies on
ECore).


> Are you sure you won't need to serialize your objects as XML and you
> won't need to build a UI for them? What will you do with them?

I won't need a UI for them but I will maybe need to serialize them (for
that purpose I usually use JAXB). EMF provide some easier ways to achieve
what I need using an XML Schema (XSD) ?

Thanks a lot for your help,

Joël

> joel wrote:
>> Hi all,
>>
>> I'm trying to generate my Java domain class from my UML2 model. For
>> that purpose I did a class diagram using Eclipse UML2 plugin, I
>> generated its related EMF model and then loaded it into a genmodel, as
>> given here:
>>
http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.u ml2tools/msg00703.html
>>
>>
>> The problem is that each class are extending EObject, etc. As I
>> understood (I'm new to EMF), EMF seems to be a "model of a model"
>> definition.
>> On my side, I only want to get my UML diagram as Java class without
>> having any EObject inheritence. Is there a way to simply achieve this ?
>>
>> Thank you in advance.
>>
>> Best regards,
>>
>> Joël
>>
>>
>>
>>
Re: UML2 to Java class without any ECore dependencies [message #58841 is a reply to message #58816] Sat, 21 March 2009 13:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25747
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010007010609010308090409
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Jo
Re: UML2 to Java class without any ECore dependencies [message #58866 is a reply to message #58765] Sat, 21 March 2009 13:38 Go to previous messageGo to next message
Krzysztof Kowalczyk is currently offline Krzysztof Kowalczyk
Messages: 113
Registered: July 2009
Senior Member
joel pisze:
> Hi all,
>
> I'm trying to generate my Java domain class from my UML2 model. For that
> purpose I did a class diagram using Eclipse UML2 plugin, I generated its
> related EMF model and then loaded it into a genmodel, as given here:
> http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.u ml2tools/msg00703.html
>
>
> The problem is that each class are extending EObject, etc. As I
> understood (I'm new to EMF), EMF seems to be a "model of a model"
> definition.
> On my side, I only want to get my UML diagram as Java class without
> having any EObject inheritence. Is there a way to simply achieve this ?
>

You can check
http://www.fornax-platform.org/cp/display/fornax/JavaBasic+(CJB)
it is based on Xpand. IMHO Xpand is best when it comes to reusing
existing cartridges, because aspect oriented features allow you to
customize what is generated easily.

Making your own basic transformation for your needs is easy. Making a
good general transformation is hard, so there are not many of them. With
all of them your UML model will need to follow some conventions.

Regards,
Krzysztof Kowalczyk
Re: UML2 to Java class without any ECore dependencies [message #58889 is a reply to message #58841] Sat, 21 March 2009 13:58 Go to previous messageGo to next message
joel is currently offline joel
Messages: 17
Registered: July 2009
Junior Member
Ed,

Thanks for your quick reply !

> Yes, all models support serialization to XML. You can read about it here:

>
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/references/overview/EMF.html

Ok, I will have a look ! I guess it use JAXB behind the scene...

> When generating the code, if you invoke Generate Test Code there will be
> a *.tests project and in there will be an XyzExample.java that shows how
> to load and save instances of your model. With Teneo, you'll also
> automatically have support for JPA or Hibernate as well.

Yes, just saw that a few minutes ago ! The hbm generation looks really
interesting !

> I find it's very common for folks to think they don't need EMF and then
> spending a lot of time manually doing things that EMF would do
> automatically.

You are totally right ! On my side, EMF still looks quite obscure. I still
don't really understand if it is only related to Eclipse RCP and I'm not
able to clearly see possible use cases of EMF usage into a project...

Will have a look to the like you gave me !

Thanks again,

Joël


>>> joel wrote:
>>>> Hi all,
>>>>
>>>> I'm trying to generate my Java domain class from my UML2 model. For
>>>> that purpose I did a class diagram using Eclipse UML2 plugin, I
>>>> generated its related EMF model and then loaded it into a genmodel,
>>>> as given here:
>>>>
>>
http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.u ml2tools/msg00703.html
>>
>>>>
>>>>
>>>> The problem is that each class are extending EObject, etc. As I
>>>> understood (I'm new to EMF), EMF seems to be a "model of a model"
>>>> definition.
>>>> On my side, I only want to get my UML diagram as Java class without
>>>> having any EObject inheritence. Is there a way to simply achieve this ?
>>>>
>>>> Thank you in advance.
>>>>
>>>> Best regards,
>>>>
>>>> Joël
>>>>
>>>>
>>>>
>>>>
>>
>>
Re: UML2 to Java class without any ECore dependencies [message #58914 is a reply to message #58866] Sat, 21 March 2009 14:01 Go to previous messageGo to next message
joel is currently offline joel
Messages: 17
Registered: July 2009
Junior Member
Hi Krzysztof,

Thanks for the hint but I was more looking for a "standard" (out of the
box) way of generating Java Code from UML without having to define a
transformation model...

Thanks anyway,

Joël

Krzysztof Kowalczyk wrote:

> You can check
> http://www.fornax-platform.org/cp/display/fornax/JavaBasic+(CJB)
> it is based on Xpand. IMHO Xpand is best when it comes to reusing
> existing cartridges, because aspect oriented features allow you to
> customize what is generated easily.

> Making your own basic transformation for your needs is easy. Making a
> good general transformation is hard, so there are not many of them. With
> all of them your UML model will need to follow some conventions.

> Regards,
> Krzysztof Kowalczyk
Re: UML2 to Java class without any ECore dependencies [message #58939 is a reply to message #58889] Sat, 21 March 2009 14:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25747
Registered: July 2009
Senior Member
Joël,

Comments below.

joel wrote:
> Ed,
>
> Thanks for your quick reply !
>
>> Yes, all models support serialization to XML. You can read about it
>> here:
>
>>
> http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/references/overview/EMF.html
>
>
> Ok, I will have a look ! I guess it use JAXB behind the scene...
No. That's one of the many advantages of having a model. The Ecore
model of the instance is available at runtime so services like XML
serialization can be implemented a generic way once and for using EMF
reflection. Copying, structural equality checking, change recording
(with undo/redo support), structural comparison, and so on are all based
on this.
>
>> When generating the code, if you invoke Generate Test Code there will
>> be a *.tests project and in there will be an XyzExample.java that
>> shows how to load and save instances of your model. With Teneo,
>> you'll also automatically have support for JPA or Hibernate as well.
>
> Yes, just saw that a few minutes ago ! The hbm generation looks really
> interesting !
Once you have a model, the possibilities are quite amazing.
>
>> I find it's very common for folks to think they don't need EMF and
>> then spending a lot of time manually doing things that EMF would do
>> automatically.
>
> You are totally right ! On my side, EMF still looks quite obscure. I
> still don't really understand if it is only related to Eclipse RCP and
> I'm not able to clearly see possible use cases of EMF usage into a
> project...
All the EMF model code and the EMF runtime work stand alone so can be
reused in any type of Java application.
>
> Will have a look to the like you gave me !
I think that will help at least get an overview.
>
> Thanks again,
>
> Joël
>
>
>>>> joel wrote:
>>>>> Hi all,
>>>>>
>>>>> I'm trying to generate my Java domain class from my UML2 model.
>>>>> For that purpose I did a class diagram using Eclipse UML2 plugin,
>>>>> I generated its related EMF model and then loaded it into a
>>>>> genmodel, as given here:
>>>>>
>>>
> http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.u ml2tools/msg00703.html
>
>>>
>>>>>
>>>>>
>>>>> The problem is that each class are extending EObject, etc. As I
>>>>> understood (I'm new to EMF), EMF seems to be a "model of a model"
>>>>> definition.
>>>>> On my side, I only want to get my UML diagram as Java class
>>>>> without having any EObject inheritence. Is there a way to simply
>>>>> achieve this ?
>>>>>
>>>>> Thank you in advance.
>>>>>
>>>>> Best regards,
>>>>>
>>>>> Joël
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Re: UML2 to Java class without any ECore dependencies [message #58964 is a reply to message #58939] Sat, 21 March 2009 14:15 Go to previous messageGo to next message
joel is currently offline joel
Messages: 17
Registered: July 2009
Junior Member
Ed,

>> Ok, I will have a look ! I guess it use JAXB behind the scene...
> No. That's one of the many advantages of having a model. The Ecore
> model of the instance is available at runtime so services like XML
> serialization can be implemented a generic way once and for using EMF
> reflection. Copying, structural equality checking, change recording
> (with undo/redo support), structural comparison, and so on are all based
> on this.

Ah, ok I understand now why everything is extending some ECore stuff :-)


> All the EMF model code and the EMF runtime work stand alone so can be
> reused in any type of Java application.
>>

Ah okay ! Would be nice to have a paper like: "what EMF provides and what
it does not provides"

So I only need to add a single Maven artifactId to my POM in order to have
it in my app as standalone ?

>> Will have a look to the like you gave me !
> I think that will help at least get an overview.

Will definitively have a look to it !

Regards,

Joël


>>>>> joel wrote:
>>>>>> Hi all,
>>>>>>
>>>>>> I'm trying to generate my Java domain class from my UML2 model.
>>>>>> For that purpose I did a class diagram using Eclipse UML2 plugin,
>>>>>> I generated its related EMF model and then loaded it into a
>>>>>> genmodel, as given here:
>>>>>>
>>>>
>>
http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.u ml2tools/msg00703.html
>>
>>>>
>>>>>>
>>>>>>
>>>>>> The problem is that each class are extending EObject, etc. As I
>>>>>> understood (I'm new to EMF), EMF seems to be a "model of a model"
>>>>>> definition.
>>>>>> On my side, I only want to get my UML diagram as Java class
>>>>>> without having any EObject inheritence. Is there a way to simply
>>>>>> achieve this ?
>>>>>>
>>>>>> Thank you in advance.
>>>>>>
>>>>>> Best regards,
>>>>>>
>>>>>> Joël
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
Re: UML2 to Java class without any ECore dependencies [message #58989 is a reply to message #58914] Sat, 21 March 2009 14:26 Go to previous messageGo to next message
Krzysztof Kowalczyk is currently offline Krzysztof Kowalczyk
Messages: 113
Registered: July 2009
Senior Member
joel pisze:
> Hi Krzysztof,
>
> Thanks for the hint but I was more looking for a "standard" (out of the
> box) way of generating Java Code from UML without having to define a
> transformation model...

The first link is an out of box transformation. But it does need some
components to be installed in your Eclipse. I think it is more
convenient than using EMF to generate plain Java. But using normal EMF
is worth considering.

> Ah okay ! Would be nice to have a paper like: "what EMF provides and
> what it does not provides"

Actually there is
http://www.informit.com/store/product.aspx?isbn=978032133188 5

I am reading it and it's really good. Great job guys :)

Regards,
Krzysztof Kowalczyk
Re: UML2 to Java class without any ECore dependencies [message #59014 is a reply to message #58964] Sat, 21 March 2009 14:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25747
Registered: July 2009
Senior Member
Joël,

Comments below.


joel wrote:
> Ed,
>
>>> Ok, I will have a look ! I guess it use JAXB behind the scene...
>> No. That's one of the many advantages of having a model. The Ecore
>> model of the instance is available at runtime so services like XML
>> serialization can be implemented a generic way once and for using EMF
>> reflection. Copying, structural equality checking, change recording
>> (with undo/redo support), structural comparison, and so on are all
>> based on this.
>
> Ah, ok I understand now why everything is extending some ECore stuff :-)
Exactly. EObject.eClass() is just like java.lang.Object.getClass()...
>
>
>> All the EMF model code and the EMF runtime work stand alone so can be
>> reused in any type of Java application.
>>>
>
> Ah okay ! Would be nice to have a paper like: "what EMF provides and
> what it does not provides"
We have a whole book.

http://www.amazon.com/gp/product/0321331885/

EM provides everything you need...
>
> So I only need to add a single Maven artifactId to my POM in order to
> have it in my app as standalone ?
I don't know about Maven and POM. The minimal runtime consists of
org.eclipse.emf.common, org.eclipse.emf.ecore, and
org.eclipse.emf.ecore.xmi (if you want XML serialization). The jarred
plugins themselves work on any classpath, so that and your own generated
models is all you need.
>
>>> Will have a look to the like you gave me !
>> I think that will help at least get an overview.
>
> Will definitively have a look to it !
>
> Regards,
>
> Joël
>
>>>>>> joel wrote:
>>>>>>> Hi all,
>>>>>>>
>>>>>>> I'm trying to generate my Java domain class from my UML2 model.
>>>>>>> For that purpose I did a class diagram using Eclipse UML2
>>>>>>> plugin, I generated its related EMF model and then loaded it
>>>>>>> into a genmodel, as given here:
>>>>>>>
>>>>>
>>>
> http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.u ml2tools/msg00703.html
>
>>>
>>>>>
>>>>>>>
>>>>>>>
>>>>>>> The problem is that each class are extending EObject, etc. As I
>>>>>>> understood (I'm new to EMF), EMF seems to be a "model of a
>>>>>>> model" definition.
>>>>>>> On my side, I only want to get my UML diagram as Java class
>>>>>>> without having any EObject inheritence. Is there a way to simply
>>>>>>> achieve this ?
>>>>>>>
>>>>>>> Thank you in advance.
>>>>>>>
>>>>>>> Best regards,
>>>>>>>
>>>>>>> Joël
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Re: UML2 to Java class without any ECore dependencies [message #59064 is a reply to message #59014] Sun, 22 March 2009 19:08 Go to previous message
joel is currently offline joel
Messages: 17
Registered: July 2009
Junior Member
Hello Ed,

Thank you for all your hints !

Best regards.

Joël
Previous Topic:de.itemis.xtext.antlr breaks
Next Topic:Re: Force UTF-8 for JET templates
Goto Forum:
  


Current Time: Sun Apr 20 03:08:01 EDT 2014

Powered by FUDForum. Page generated in 0.02617 seconds