UML to JEE : Using UML Profiles

From AcceleoWiki

Jump to: navigation, search

Contents

Definition

A profile in the Unified Modeling Language provides a generic extension mechanism for customizing UML models for particular domains and platforms. Profiles are defined using stereotypes, tagged values, and constraints that are applied to specific model elements, such as Classes, Attributes, Operations, and Activities. A Profile is a collection of such extensions that collectively customize UML for a particular domain (e.g., aerospace, healthcare, financial) or platform (J2EE, .NET).

[definition from the Wikipedia]

Profile for UML2 Eclipse plugin

MDT UML2 component in action
MDT UML2 component in action

In the "Eclipse World" most of the UML application are base on the MDT UML2 Component. This plugin brings an EMF implementation of the UML2 meta-model and give a standard framework for anyone who wants to create a tool based on the UML2 meta-model. Acceleo (and so the module based on UML2) use this framework during generation on UML2 based models.

This implementation allows to define profiles for the purpose described in the definition. The rest of this page explains how to use profile with this implementation of UML2.

Applying and using existing profile

The method to apply and use an existing profile on a uml model depend of the modeler use to create the model. In this section, the method for some common modelers are described.

UML2 hierarchical modeler

To use a elements of an UML profile, the first step is to apply it on the package containing the element to extend. To apply a profile on a UML package, the model containing the profile must be loaded. To load a profile, perform a right on the model and run "load model".


Image:UML to JEE - Apply a profile 1.png


Then enter the path of the model. Generally, URIs start with plateform://resource/ for models in workspace of plateform://plugin/ for models in plugin. An other possibility is to use pathmap. Pathmap is a EMF mechanisme to logically reference models and not physically. Thus, business profile have the pathmap pathmap://ACCELEO_PROFILES/Acceleo.Business.profile.uml so to use it, type in the load resource dialog it.


Image:UML to JEE - Apply a profile 2.png


Once loaded, the model appears at the end of the modeler.


Image:UML to JEE - Apply a profile 3.png


After, it's possible to apply the containing profiles in the model. In order to apply the business profile on a package, select the target package in the modeler and then, use the "Package >> Apply Profile..." entry of the modeler's menu.


Image:UML to JEE - Apply a profile 4.png


In the new dialog, select the profiles to apply (in our case, the Acceleo::Business profile) and click on "Add" button. All the profiles in the right list will be applied on the selected package once the "OK" button pressed.


Image:UML to JEE - Apply a profile 5.png


When a profile is applied, a "Profile Application" appears in the target package.


Image:UML to JEE - Apply a profile 6.png


Once a profile is applied on a package, all the elements of this package (Stereotype, Tagged values, ...) are usable with the element containing in the package. In our case, we can apply the «Service» stereotype on the class of the package. To do that, select the target class and launch the "Element >> Apply Stereotype..." action of the modeler's menu.


Image:UML to JEE - Using a profile 1.png


Similarly to the profile application, select all the stereotypes to apply on the element, click on "Add" and "OK". All the selected stereotypes are applied on the element.


Image:UML to JEE - Using a profile 2.png


The applied stereotypes are displayed enclosed by guillemets in the modeler.


Image:UML to JEE - Using a profile 3.png

TopCased editor

As with the hierarchical modeler, the first step to apply a profile is to load the model containing this profile. Right click on the outline view of the editor and launch "Load resource .." action.


Image:UML to JEE - TopCased - Apply a profile 1.png


Type the pathmap of the Acceleo Business profile.


Image:UML to JEE - Apply a profile 2.png


The model containing the profile appears at the end of the outline.


Image:UML to JEE - TopCased - Apply a profile 3.png


Then, click on the package upon which to apply the profile and open the properties view if not already ("Right click > Show Property"). In the profile tab, select the profile to apply and click on the "Add" button. Save the modification


Image:UML to JEE - TopCased - Apply a profile 4.png


Select the class upon which apply the stereotype. In the stereotype tab of the properties view, select the stereotype to apply and click on the "Add" button. Save the modification.


Image:UML to JEE - TopCased - Using a profile 2.png


The stereotype must appears in the editor.


Image:UML to JEE - TopCased - Using a profile 3.png

Extending existing profile

[To complete]

Personal tools