UML 2.1 to Java
From AcceleoWiki
| Module UML 2.1 to Java | |
| |
| Status: | Incubation |
| Licence: | EPL |
| Target: | Java |
| Metamodel: | UML 2.1 |
| Inital contributor: | CEA Obeo |
| Contact: | Gonzague Reydet |
This project aims to generate Java applications from UML 2.1 models.
Contents |
Guidelines
- Easy to use
- Standard UML input model (no complex UML profile)
Features
- Java files generated from model elements:
- Classes
- Interfaces
- Enumerations
- Generated files respect the package structure
- Comments generated from comment model elements
- Association management
- Generalization management
- Interface realization management
- Accessors generation
Planned features
- Implementation of abstract methods from interface realizations and inherited abstract class
- Method return generation
- Constructors generation
Installation
The installation process is described on the installing a module web page.
Contribute!
- Access to the project sources using the Team Project Set file of the UML 2.1 to Java generator module. Understand how to use this file reading the tutorial: how to get and modify generator module sources.
- To report a bug, use the Acceleo module tracker.
How to use the generator?
Create a Module Launcher Chain
In a project (Java project), containing thbahe input UML model, clic on "New > Other..." and select "Module Launcher" on the Acceleo folder:

Then, select the UML 2.1 to Java generation module:

Then, give a name to your new chain:

Finally, enter the 3 parameters required by this generation module:
- The error log file
- The output source folder
- The input UML model
Launch the generation
To launch the generation process, right click on the chain, then "Launch":
Upon the generation process completed, the generated sources should appear on the specified output folder.
Optional parameters
Several parameters can be set to personalize the generation:
| Property name | Description | Default value |
|---|---|---|
| tuple.genArrays | Set the representation of multiple attributes. Can be either arrays or collections | false |
| tuple.ordered.class | Set the class used for ordered collections | java.util.ArrayList |
| tuple.notOrdered.class | Set the class used for not ordered collections | java.util.HashSet |
| gen.accessors | Enable/Disable accessor generation (get/set) | true |
| gen.listAccessors | Enable/Disable list accessor generation (add/remove) | true |
| gen.biDirections | Enable/Disable bi-directionality generation | true |
| gen.comment.date | Enable/disable the date/time generation in code heading comments | true |
To precise such parameters to the generation module, add a property file (with .properties extension) next to the chain you created to launch the generation. For example, you can create a file UML2Java.properties with the following content:
# Generate arrays instead of collections tuple.genArrays=true # Don't generate accessors gen.genAccessors=false # Don't add generation date and time in code heading comments gen.comment.date=false


