Using UML profiles
Declaring UML profiles
UML profiles
are declared in MDA Modeler.
For more information, please see the "MDA Modeler User Guide".
Absolute or relative UML profile notation in programming
Absolute UML profile notation is carried out independently of the current UML profile. It starts from the root (default), either with a notation written "default#P1#P2", or by using the "#" character (#P1#P2).
Relative UML profile notation can use the "-" symbol to move up the UML profile hierarchy, starting from the current UML profile.
Redefining methods
By default, a "child" UML profile owns all the features that are defined for its "parent" UML profiles. However, it is also possible to redefine in the child UML profile features present in the parent UML profile. In this case, the child's features mask those of the parent. For example, "V3_2" uses the "Cxx" generation rules, but redefines some of its methods.
Navigation example
In the
"Cxx" UML profile, the "generate" method in
"V3_2" can be accessed in several ways:
#external#Code#Cxx#V3_2#generate(); //Absolute notation
or
V3_2#generate();
// Relative notation
The
"generate" method in "design" can be accessed in several
ways:
#documentation#design#generate(); //Absolute notation
//or
(Relative notation)
-#-#documentation#design#generate();
Current UML profile
The current UML profile is evaluated during execution. It corresponds to the last explicitly specified UML profile and can be:
· the UML profile that triggers the J program (that of the program's user).
· a UML profile explicitly specified, in an absolute or relative way during the method call. When the method returns, the previous UML profile becomes current again.
Relative UML profile
A relative UML profile is evaluated according to the declaration UML profile of the embedding method. UML profiles expressed in a relative way are not evaluated according to the current UML profile, which is known dynamically. This does not allow you to know, during the writing of the J method, the UML profile which is finally chosen.
Example
#external#Code#Cxx#generate() package; (1)
#external#Code#generate() class; (2)
#external#Code#Cxx#V3_2#generate() class; (3)
#documentation#print() class; (4)
#documentation#generate() class; (5)
If a user in the "#external#Code#Cxx#V3_2#" UML profile calls "generate()" on a package, (1) will be triggered.
If the code of (1) triggers "‑#documentation#generate()" on a class, the (5) method is called (declaration viewpoint = "Cxx").
If the code of (1) triggers "generate()" on a class, method (3) is triggered (current UML profile = v3_2).
If this last method explicitly calls "#documentation#print()", then "print()" is called with the new current "#documentation" UML profile. In this case, a call of "generate()" will trigger method (5) available in this UML profile.
Accessing features of a UML profile without changing current UML profile
The "##"
notation, placed between the UML profile and the feature, is used to
specify a UML access profile, which allows access to the feature without
changing the current UML profile.
Example
In the
external#Code#Cxx UML profile, the "init" method calls "init2".
In the #external#Code#Cxx#V3_2 UML profile, we want
these methods to be redefined and the redefined version of init2 to be called
by init of the #external#Code#Cxx UML profile.
//in the
external#Code#Cxx UMLProfile
Class:#external#Code#Cxx#init()
{
...
init2();
...
}
Class:#external#Code#Cxx#init2();
{
...
}
// the redefinitions in #external#Code#Cxx#V3_2 Class:#external#Code#Cxx#V3_2#init2();
{
...
}
Class:#external#Code#Cxx#V3_2#init();
{
...
// Calling of init of the superior UML profile
// without changing the current UML profile so that
// the init2 of V3_2 be called by init of Cxx
-##init();
...
}
Navigation rule
If, for example, an M method is called without any specified UML profile, J will search M firstly on:
· the current class and in the current UML profile
· a class parent to the current class and in the current UML profile
· the current class and in a parent UML profile
· a class parent to the current class and in a parent UML profile
Example
With the
following method definitions:
Object:#default#Cxx#V3_2#generate();
Class:#default#Cxx#generate();
If the
"generate()" message is sent to the "Class"
class in the "V3_2" UML profile, the following method will be
called:
"Object:"#default#Cxx#V3_2#generate();"