AndroMDA Profiles

Because the profile ia a namespace component it MUST be registered within a namespace descriptor . This descriptor is what allows the profile's namespace to be "discovered" on the classpath. This namespace descriptor also registers the profile component within the AndroMDA core.

People sometimes ask: "Can I change the stereotype names?, I really don't like using the capitalized <<Entity>> to denote an entity, I'd rather use the lowercase <<entity>> instead." Well in order to provide this ability to customize existing AndroMDA profiles (as well as creating your own), AndroMDA has the concept of customizable profile descriptors. This XML configuration file (which is typically located at META-INF/andromda/profile.xml with a cartridge or metafacade jar) allows someone using AndroMDA to map stereotypes, tagged values, and data types to ANY names he or she wants without having to change ANY code.

Each profile file must adhere to this XML Schema .

Lets have a look at the contents of what a typical profile.xml file might contain (this snippet was taken from the UML metafacades META-INF/andromda/profile.xml file):


<
profile
> <
elements
> <
elementGroup
name=
"Stereotypes"
> <
element
name=
"CRITERIA"
> <
documentation
><
/documentation
> <
value
>Criteria<
/value
> <
/element
> <
element
name=
"ENTITY"
> <
documentation
><
/documentation
> <
value
>Entity<
/value
> <
/element
> ... <
/elementGroup
> <
elementGroup
name=
"Tagged Values"
> <
element
name=
"DOCUMENTATION"
> <
documentation
><
/documentation
> <
value
>documentation<
/value
> <
/element
> <
element
name=
"HYPERLINK"
> <
documentation
>Represents a hyperlink within a model<
/documentation
> <
value
>hyperlink<
/value
> <
/element
> <
element
name=
"PERSISTENCE_TABLE"
> <
documentation
><
/documentation
> <
value
>@andromda.persistence.table<
/value
> <
/element
> <
element
name=
"PERSISTENCE_COLUMN"
> <
documentation
><
/documentation
> <
value
>@andromda.persistence.column<
/value
> <
/element
> <
element
name=
"PERSISTENCE_COLUMN_LENGTH"
> <
documentation
><
/documentation
> <
value
>@andromda.persistence.column.length<
/value
> <
/element
> ... <
/elementGroup
> <
elementGroup
name=
"Data Types"
> <
element
name=
"COLLECTION_TYPE"
> <
documentation
><
/documentation
> <
value
>datatype::Collection<
/value
> <
/element
> <
element
name=
"LIST_TYPE"
> <
documentation
><
/documentation
> <
value
>datatype::List<
/value
> <
/element
> <
element
name=
"SET_TYPE"
> <
documentation
><
/documentation
> <
value
>datatype::Set<
/value
> <
/element
> ... <
/elementGroup
> <
/elements
> <
/profile
>

If you'll take a closer look at the above example, you'll notice that the name attribute contains the constant, and the contents of the value element contains the value to which the constant is mapped (this is the value that corresponds to the profile element in your model). These XML profiles (typically located at META-INF/andromda/profile.xml of a cartridge or metafacades jar) are loaded during AndroMDA startup and made available to the framework.

Overriding Profile Values

In order to customize a specific mapped profile value, one must override that value by creating his/her own profile mapping and letting AndroMDA know its location by using the profileMappingsUri property. For example, this profile mappings file below would allow us to change the stereotype indentifying an entity to <<entity>> instead of the default <<Entity>> (the ENTITY profile constant is defined in the profile.xml of the UML metafacades jar which we saw above). Once we provide this customized mappings file AndroMDA will now recognize model elements with the stereotype <<entity>> :


<
profile
> ... <
element
name=
"ENTITY"
> <
value
>entity<
/value
> <
/element
> ... <
/profile
>
After writing your profile, you'd then define the location of this mappings file as the namespace property profileMappingsUri (within the mda/conf/andromda.xml file), like we do here (notice that the path must be a URI):

<
namespace
name=
"default"
> <
properties
> ... <
property
name=
"profileMappingsUri"
>file:${basedir}/mda/conf/mappings/CustomizedProfileMappings.xml<
/property
> ... <
/properties
> <
/namespace
>