Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 Tools » Generate Java code from UML model
Generate Java code from UML model [message #476548] Fri, 19 June 2009 08:16 Go to next message
Eclipse UserFriend
Originally posted by: michael.gebhart.googlemail.com

Hi,

I've created some UML models (class diagrams) and now, I want to
generate the Java code skeletons. Is this possible?

I've tried to convert the UML models to an Ecore model and gen model and
generated the Java code. But now, I have my classes that inherit from
EObject and the code contains a lot of annotations. I only want to
generate plain Java objects. Is this possible with the Eclipse UML Tools
(I am already testing the Galileo release). Or is there an open source
plug-in available?

Greetings

Michael
Re: Generate Java code from UML model [message #476549 is a reply to message #476548] Fri, 19 June 2009 08:54 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 362
Registered: July 2009
Senior Member
Michael, the UML2 Tools project deals with modeling only. You will find
3 different code generation solutions in the M2T project (which I added
to the CC list): XPand, Acceleo and JET. Here is the project web site:

http://www.eclipse.org/modeling/m2t/

Cheers,

Rafael
http://abstratt.com/blog/

Michael Gebhart wrote:
> Hi,
>
> I've created some UML models (class diagrams) and now, I want to
> generate the Java code skeletons. Is this possible?
>
> I've tried to convert the UML models to an Ecore model and gen model and
> generated the Java code. But now, I have my classes that inherit from
> EObject and the code contains a lot of annotations. I only want to
> generate plain Java objects. Is this possible with the Eclipse UML Tools
> (I am already testing the Galileo release). Or is there an open source
> plug-in available?
>
> Greetings
>
> Michael
Re: Generate Java code from UML model [message #476550 is a reply to message #476548] Fri, 19 June 2009 09:05 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Michael,

I'll bet that in the end you need 95% of what EMF generates for you but
just don't realize it yet. After all, won't you need to be able persist
your instance as XML or to a data base, or build a UI for them? Note
that you can suppress EObject (Suppress EMF Types) and the @model
annotations (Suppress EMF Annotations) from the interfaces with settings
in the GenModel.


Michael Gebhart wrote:
> Hi,
>
> I've created some UML models (class diagrams) and now, I want to
> generate the Java code skeletons. Is this possible?
>
> I've tried to convert the UML models to an Ecore model and gen model
> and generated the Java code. But now, I have my classes that inherit
> from EObject and the code contains a lot of annotations. I only want
> to generate plain Java objects. Is this possible with the Eclipse UML
> Tools (I am already testing the Galileo release). Or is there an open
> source plug-in available?
>
> Greetings
>
> Michael


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Generate Java code from UML model [message #476551 is a reply to message #476548] Fri, 19 June 2009 10:58 Go to previous messageGo to next message
Vlad Varnica is currently offline Vlad VarnicaFriend
Messages: 546
Registered: July 2009
Location: Milton Keynes - UK
Senior Member
Hi Michael,

You can use EMF as explained by Ed, Acceleo, XPand, Jet as explained by
Rafael or load the model inside EclipseUML 2008. Sorry guys to come back
and talk about Omondo but this question is related to Java.
EclipseUML is not free or open source and we are very very expensive
therefore if you have no budget the best is to use Ed or Rafeal tips. :-)

You just need to paste and copy your .uml file in the package explorer.
Create a class diagram with EclipseUML, and then drag and drop one of your
classifier inside the existing class diagram. At first element drop your
model is immediately merged with the exiting EclipseUML project model. You
can for example merge as many model as you want, no limit.

Once the model has been merged, you need to drag and drop from the XMI
editor to the class diagram all the classifiers for which you would like
to generate code and finally you click on the class diagram background to
open the class diagram contextual menu > Transform to Java. This will
create the skeleton of your java code. Note that the UML Id remain the
same as the UML classifier which was created in your first time created
model. This is important for traceability purposes and model
transformation without loosing modeling information.
Re: Generate Java code from UML model [message #476554 is a reply to message #476549] Fri, 19 June 2009 21:52 Go to previous messageGo to next message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Michael,

what you have done is, you've created an Ecore-based DSL of your model.
In this case, your UML instance model was converted into a arbitrary
metamodel (M2). What you wanted to do is to generate code out of UML
instance model.

Therefore, as Rafael mentioned, there are severals projects, but none
out-of-the-box-solution. I can recommend JET2 and Acceleo. I've worked
with both and they are feasible for your problem.

HTH
/Timothy

Rafael Chaves schrieb:
> Michael, the UML2 Tools project deals with modeling only. You will find
> 3 different code generation solutions in the M2T project (which I added
> to the CC list): XPand, Acceleo and JET. Here is the project web site:
>
> http://www.eclipse.org/modeling/m2t/
>
> Cheers,
>
> Rafael
> http://abstratt.com/blog/
>
> Michael Gebhart wrote:
>> Hi,
>>
>> I've created some UML models (class diagrams) and now, I want to
>> generate the Java code skeletons. Is this possible?
>>
>> I've tried to convert the UML models to an Ecore model and gen model
>> and generated the Java code. But now, I have my classes that inherit
>> from EObject and the code contains a lot of annotations. I only want
>> to generate plain Java objects. Is this possible with the Eclipse UML
>> Tools (I am already testing the Galileo release). Or is there an open
>> source plug-in available?
>>
>> Greetings
>>
>> Michael
Re: Generate Java code from UML model [message #476555 is a reply to message #476554] Mon, 22 June 2009 09:22 Go to previous message
Stephane Bouchet is currently offline Stephane BouchetFriend
Messages: 280
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040206070205090400000006
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi,

there is a light example of doing this under the acceleo examples.

Just install Acceleo, right click on the .uml file, and you would be
able to generate java sources files.


Cheers,



Timothy Marc a
Re: Generate Java code from UML model [message #624300 is a reply to message #476548] Fri, 19 June 2009 08:54 Go to previous message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 362
Registered: July 2009
Senior Member
Michael, the UML2 Tools project deals with modeling only. You will find
3 different code generation solutions in the M2T project (which I added
to the CC list): XPand, Acceleo and JET. Here is the project web site:

http://www.eclipse.org/modeling/m2t/

Cheers,

Rafael
http://abstratt.com/blog/

Michael Gebhart wrote:
> Hi,
>
> I've created some UML models (class diagrams) and now, I want to
> generate the Java code skeletons. Is this possible?
>
> I've tried to convert the UML models to an Ecore model and gen model and
> generated the Java code. But now, I have my classes that inherit from
> EObject and the code contains a lot of annotations. I only want to
> generate plain Java objects. Is this possible with the Eclipse UML Tools
> (I am already testing the Galileo release). Or is there an open source
> plug-in available?
>
> Greetings
>
> Michael
Re: Generate Java code from UML model [message #624301 is a reply to message #476548] Fri, 19 June 2009 09:05 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Michael,

I'll bet that in the end you need 95% of what EMF generates for you but
just don't realize it yet. After all, won't you need to be able persist
your instance as XML or to a data base, or build a UI for them? Note
that you can suppress EObject (Suppress EMF Types) and the @model
annotations (Suppress EMF Annotations) from the interfaces with settings
in the GenModel.


Michael Gebhart wrote:
> Hi,
>
> I've created some UML models (class diagrams) and now, I want to
> generate the Java code skeletons. Is this possible?
>
> I've tried to convert the UML models to an Ecore model and gen model
> and generated the Java code. But now, I have my classes that inherit
> from EObject and the code contains a lot of annotations. I only want
> to generate plain Java objects. Is this possible with the Eclipse UML
> Tools (I am already testing the Galileo release). Or is there an open
> source plug-in available?
>
> Greetings
>
> Michael


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Generate Java code from UML model [message #624302 is a reply to message #476548] Fri, 19 June 2009 10:58 Go to previous message
Vlad Varnica is currently offline Vlad VarnicaFriend
Messages: 546
Registered: July 2009
Location: Milton Keynes - UK
Senior Member
Hi Michael,

You can use EMF as explained by Ed, Acceleo, XPand, Jet as explained by
Rafael or load the model inside EclipseUML 2008. Sorry guys to come back
and talk about Omondo but this question is related to Java.
EclipseUML is not free or open source and we are very very expensive
therefore if you have no budget the best is to use Ed or Rafeal tips. :-)

You just need to paste and copy your .uml file in the package explorer.
Create a class diagram with EclipseUML, and then drag and drop one of your
classifier inside the existing class diagram. At first element drop your
model is immediately merged with the exiting EclipseUML project model. You
can for example merge as many model as you want, no limit.

Once the model has been merged, you need to drag and drop from the XMI
editor to the class diagram all the classifiers for which you would like
to generate code and finally you click on the class diagram background to
open the class diagram contextual menu > Transform to Java. This will
create the skeleton of your java code. Note that the UML Id remain the
same as the UML classifier which was created in your first time created
model. This is important for traceability purposes and model
transformation without loosing modeling information.
Re: Generate Java code from UML model [message #624305 is a reply to message #476549] Fri, 19 June 2009 21:52 Go to previous message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Michael,

what you have done is, you've created an Ecore-based DSL of your model.
In this case, your UML instance model was converted into a arbitrary
metamodel (M2). What you wanted to do is to generate code out of UML
instance model.

Therefore, as Rafael mentioned, there are severals projects, but none
out-of-the-box-solution. I can recommend JET2 and Acceleo. I've worked
with both and they are feasible for your problem.

HTH
/Timothy

Rafael Chaves schrieb:
> Michael, the UML2 Tools project deals with modeling only. You will find
> 3 different code generation solutions in the M2T project (which I added
> to the CC list): XPand, Acceleo and JET. Here is the project web site:
>
> http://www.eclipse.org/modeling/m2t/
>
> Cheers,
>
> Rafael
> http://abstratt.com/blog/
>
> Michael Gebhart wrote:
>> Hi,
>>
>> I've created some UML models (class diagrams) and now, I want to
>> generate the Java code skeletons. Is this possible?
>>
>> I've tried to convert the UML models to an Ecore model and gen model
>> and generated the Java code. But now, I have my classes that inherit
>> from EObject and the code contains a lot of annotations. I only want
>> to generate plain Java objects. Is this possible with the Eclipse UML
>> Tools (I am already testing the Galileo release). Or is there an open
>> source plug-in available?
>>
>> Greetings
>>
>> Michael
Re: Generate Java code from UML model [message #624306 is a reply to message #476554] Mon, 22 June 2009 09:22 Go to previous message
Stephane Bouchet is currently offline Stephane BouchetFriend
Messages: 280
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040206070205090400000006
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi,

there is a light example of doing this under the acceleo examples.

Just install Acceleo, right click on the .uml file, and you would be
able to generate java sources files.


Cheers,



Timothy Marc a
Previous Topic:[Announce] MDT UML2TOOLS 0.9.0RC5 is available
Next Topic:UML Diagram Generation
Goto Forum:
  


Current Time: Thu Apr 25 19:52:17 GMT 2024

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

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

Back to the top