Three different development workflows are possible when using Java Architect. They essentially differ:
-
in the way the generation/edition/reverse operations can be carried out or not
-
in the format of the generated code
Each workflow corresponds to a so-called generation mode. The available modes are:
-
Round-trip mode is the default generation mode. It is the most flexible mode, the user can freely modify the generated code in his favorite IDE. It is often perceived as the easiest mode.
In round-trip mode any code modification, including structural modifications such as packages, classes, attributes, operations addition, removal or renaming, will be reversed and updated in the model.
-
Model driven mode is based on complete generation from the UML model with marked zones to edit the java code. The update command will only retrieve the code fragments between the model driven markers.
Choosing the Model driven mode means that any structural modifications like creation, deletion or renaming of classes, members or methods must first be carried out in the model otherwise they will be lost on next generation if only made in the code.
The model driven mode may be preferred when the application design needs to be strongly controlled because no structural modifications can be carried out in the code, the design is protected from unexpected code change side-effects.
Typical use cases are sub-contracting work to external contributors who are not supposed to modify the design or securing the maintenance phase of an application lifecycleby avoiding unwanted design modifications while fixing bugs.
-
In Release mode the code is generated with no additional annotation or marker at all.
No reverse is available in this mode. This mode is typically used to generate sources without trace of Modelio for final delivery or publishing.
The release mode may also be chosen when the Java model itself is programatically generated by another module and is not intended to be externally modified (automatic generation of APIs or code).
The generation mode has to be chosen at the level project, ie the generation mode is applied to the whole project. See Changing the generation mode below for full details about changing the mode.
Which generation mode and development workflow to choose is a matter of a mix of development method preferences, organization habits, technical constraints and even personal taste.
Please carefully read the description of each generation mode and workflow below in order to enlighten your choices.
Round-trip
The round trip workflow
The usual round-trip workflow is:
-
Generate the sources:
-
Select the element(s) to generate, eg the root java package or a Java component.
-
Go to the "
Java" view.
-
Click on the "
Generates '.java' files" toolbar button. You may also right click on the element and choose
Java Architect→
Generates sources .
-
-
Edit the sources
-
Use your favorite external IDE
-
Or edit the source file in Modelio
-
Select the class or interface to edit.
-
Go to the "
Java" view
-
Click on the
Opens an editor on the generated file toolbar button.
→ A source view then opens with the generated file content. -
Edit the source in the opened view.
-
Save the file with <Ctrl>+S or the "Save" button in the tool bar.
→ The model is automatically updated from the edited file .
-
-
-
Reverse the edited sources
-
Manually reverse each edited element:
-
Select the element(s) to reverse
-
In the "Java" view click on the
Update model from '.java' files toolbar button.
You may also right click on the element and choose Java Architect→
Update model from sources
-
-
Or simply run again the
Generates '.java' files command. Java Architect will automatically reverse the modified files before generating them.
-
The round-trip generated code format
package hello;
import java.util.HashMap;
import com.modeliosoft.modelio.javadesigner.annotations.mdl;
import com.modeliosoft.modelio.javadesigner.annotations.objid;
/**
* This is an hello world example.
*/
@objid ("c416c96a-92b8-4e80-92c6-6d9056462d01")
public class HelloWorld {
/**
* Stores the user name.
*/
@mdl.prop
@objid ("3140559b-c6f6-4ff7-954b-fc931ab18436")
public String name = "Bob";
@mdl.propgetter
public String getName() {
// Automatically generated method. Please delete this comment before entering specific code.
return this.name;
}
@mdl.propsetter
public void setName(final String value) {
// Automatically generated method. Please delete this comment before entering specific code.
this.name = value;
}
/**
* The main method
* @param args command line arguments
*/
@objid ("815dc70d-d16e-4937-866e-894383998805")
public static void main(String[] args) {
HelloWorld h = new HelloWorld();
if (args.length > 0)
h.setName(args[0]);
System.out.printf("Hello %s !%n", h.getName());
}
}
In order to support renaming and moving, @objid("xxx-xxx-xxx")
annotations are
added in the generated code for each java structural element (class, attribute, operation).
The model is updated when the “Update Source” command is run.
![]() |
The @objid("xxx-xxx-xxx") are used to reference model elements in Modelio.
They take precedence on the element name to recognize existing model elements in the model.
This mechanism ensures that if you rename a Java structural element in the code, the model will be updated correctly.
|
![]() |
Developers are not supposed to mess up with these @objid("xxx-xxx-xxx") annotations.
If they do it anyway the "Update source" command will do its best to recognize the already existing reversed objects
in the model but might be fooled by renamed or moved elements.
|
![]() |
A common mistake consists in copying chunks of code in the Java and including the @objid("xxx-xxx-xxx") annotations
in the copy. This leads to a situation where the reverse will find several objects identified by the same @objid("xxx-xxx-xxx") annotation.
However, Java Architect maintains your model safe because the reverse will simply fail indicating the duplicated identifier reason for the failure.
To fix this situation simply remove the duplicated id from the source code before reversing again.
|
Model driven
The Model driven workflow
The usual model driven workflow is:
-
Generate the sources:
-
Select the element(s) to generate, eg the root java package or a Java component.
-
Go to the "
Java" view.
-
Click on the "
Generates '.java' files" toolbar button. You may also right click on the element and choose
Java Architect→
Generates sources .
-
-
Edit the sources: only between the begin and end markers
-
Use your favorite external IDE
-
Or edit the source file in Modelio
-
Edit the code between the begin and end markers.
-
Go to the "
Java" view
-
Click on the
Opens an editor on the generated file toolbar button.
→ A source view then opens with the generated file content. -
Edit the source in the opened view.
-
Save the file with <Ctrl>+S or the "Save" button in the tool bar.
→ The model is automatically updated from the edited file.
-
-
-
Reverse the edited sources
-
Manually reverse each edited element:
-
Select the element(s) to reverse
-
In the "Java" view click on the
Update model from '.java' files toolbar button.
You may also right click on the element and choose Java Architect→
Update model from sources
-
-
Or simply run again the
Generates '.java' files command. Java Architect will automatically reverse the modified files before generating them.
-
![]() |
Remember that in the model driven mode, only textual code between the zone begin and end markers will be retrieved and updated in the model. These model driven zones mainly cover the body of the methods and some file zones (imports, variables and so on). The model driven code retrieve will not modify the model structure ie: no addition or deletion of Java elements will be carried out. |
The Model driven generated code format
package hello;
import java.util.HashMap;
import com.modeliosoft.modelio.javadesigner.annotations.mdl;
//begin of modifiable zone................T/c416c96a-92b8-4e80-92c6-6d9056462d01
/**
* This is an hello world example.
*/
//end of modifiable zone..................E/c416c96a-92b8-4e80-92c6-6d9056462d01
public class HelloWorld {
//begin of modifiable zone................T/3140559b-c6f6-4ff7-954b-fc931ab18436
/**
* Stores the user name.
*/
//end of modifiable zone..................E/3140559b-c6f6-4ff7-954b-fc931ab18436
public String name = "Bob";
@mdl.propgetter
//begin of modifiable zone................T/4e76af13-8ebb-4ee7-ad28-e560367f5308
//end of modifiable zone..................E/4e76af13-8ebb-4ee7-ad28-e560367f5308
public String getName() {
//begin of modifiable zone................T/4e76af13-8ebb-4ee7-ad28-e560367f5308
// Automatically generated method. Please delete this comment before entering specific code.
//end of modifiable zone..................E/4e76af13-8ebb-4ee7-ad28-e560367f5308
//begin of modifiable zone................T/4e76af13-8ebb-4ee7-ad28-e560367f5308
return this.name;
//end of modifiable zone..................E/4e76af13-8ebb-4ee7-ad28-e560367f5308
}
@mdl.propsetter
//begin of modifiable zone................T/bd2c4f07-0326-44d8-8f3e-a55762083e06
//end of modifiable zone..................E/bd2c4f07-0326-44d8-8f3e-a55762083e06
public void setName(final String value) {
//begin of modifiable zone................T/bd2c4f07-0326-44d8-8f3e-a55762083e06
// Automatically generated method. Please delete this comment before entering specific code.
this.name = value;
//end of modifiable zone..................E/bd2c4f07-0326-44d8-8f3e-a55762083e06
}
//begin of modifiable zone................T/815dc70d-d16e-4937-866e-894383998805
/**
* The main method
* @param args command line arguments
*/
//end of modifiable zone..................E/815dc70d-d16e-4937-866e-894383998805
public static void main(String[] args) {
//begin of modifiable zone................T/815dc70d-d16e-4937-866e-894383998805
HelloWorld h = new HelloWorld();
if (args.length > 0)
h.setName(args[0]);
System.out.printf("Hello %s !%n", h.getName());
//end of modifiable zone..................E/815dc70d-d16e-4937-866e-894383998805
}
}
![]() |
are zone begin markers |
![]() |
are zone end markers |
Only the methods body and some delimited zones may be modified and reversed from the code. The modifiable zones are delimited by <1> and <2> markers in the generated code. Any other modification will be lost on next generation.
Release
The Release mode workflow
There is no real workflow in this mode, just generate the code, no code modification and model update possible.
The Release mode generated code format
package hello;
import java.util.HashMap;
import com.modeliosoft.modelio.javadesigner.annotations.mdl;
/**
* This is an hello world example.
*/
public class HelloWorld {
/**
* Stores the user name.
*/
public String name = "Bob";
@mdl.propgetter
public String getName() {
// Automatically generated method. Please delete this comment before entering specific code.
return this.name;
}
@mdl.propsetter
public void setName(final String value) {
// Automatically generated method. Please delete this comment before entering specific code.
this.name = value;
}
/**
* The main method
* @param args command line arguments
*/
public static void main(String[] args) {
HelloWorld h = new HelloWorld();
if (args.length > 0)
h.setName(args[0]);
System.out.printf("Hello %s !%n", h.getName());
}
}
In release mode the code is generated with no additional annotation or marker at all. The "Update source" command is not available.
Changing the generation mode
In order to modify the mode:
-
In the main menu bar, select the "Configuration/ Modules…" menu
-
In the "Project’s module" table, select "Java Architect"
-
Go to the "Project’s modules parameters",
-
Look for "Java Architect/General/Generation mode" parameter.
-
Choose the desired mode in the combo
-
Close the dialog this the "Close" button.
![]() |
The generation mode is chosen at the level project, ie it applies to the whole project. |