Instant Messenger case study
Introduction
This is a medium-sized case study involving the automatic generation of an instant messaging client, based on context information. This case study is based on the instant messaging scenario, developed within the CoDAMoS project. The instant messaging client supports several network protocols (e.g. Jabber, SMS) and several user interfaces (e.g. AWT, Swing).
If you would like a walk-through of the entire case study, you can view the following presentation, including flash demo:
- Wagelaar, D., MDE Case Study: Using Model Transformations for UML ands DSLs, presentation/demo for JUGS, Zürich, Switzerland, 30 March 2006.
[ OpenOffice ] [ Adobe PDF ] [ Flash demo (49 min.) ]
Figure 1: Instant Messenger Screenshot
Context-Driven Development
This case study is being used in the Context-Driven Model Refinement research track. Pre-generated versions of the instant messaging client can be downloaded using the PlatformKit web servlet.
UML 2 source models
The source consists of several UML 2 models, of which one forms the “core” feature (or “concept”). The other models represent optional features and are linked to the core model. The source models for this case study can be found here (see also the installation instructions. The models were all developed using the Topcased UML2 editor. The following models (features) are available:
- InstantMessengerModel.uml
“Core” model, containing the minimal infrastructure of the instant messaging client. - InstantMessengerAWT.uml
Java AWT user interface. - InstantMessengerSwing.uml
Java Swing user interface. - InstantMessengerLCDUI.uml
Java MIDP LCDUI user interface (for mobile phones). - InstantMessengerJabber.uml
Jabber network protocol support (using the JabberWookie library). - InstantMessengerDefaultJabber.uml
Jabber default java.net.Socket transport. - InstantMessengerMEJabber.uml
Jabber MIDP javax.microedition.io.Connection transport. - InstantMessengerLocal.uml
Local/loopback network protocol support (also used for debug/error messages).
UML 2 refinement transformations
In addition, a series of refinement model transformations have to be applied before Java code can be generated. These refinement transformations sometimes introduce a part of static model content (doesn't vary based on input model) and always introduce a part of dynamic model content (varies based on input model). The static content is generally linked to the output model as a library. The available refinement transformations can be found here.
In order to manage the selection of models and the refinement transformations applied to them, a configuration meta-model has been defined. Instances of this configuration meta-model can be used to generate a 'build.xml' file and 'parameters.xml' file that will implement the modelled configuration. One extra transformation has been defined for this:
ConfigToBuildFile
This transformation generates an Ant 'build.xml' file from an instant messenger configuration model. This 'build.xml' file is a complete Ant file that contains macros and all targets for executing the 'UML2…' transformations according to the given configuration. The 'build.xml' file must be extracted using AM3 Ant tasks.
| ConfigToBuildFile.atl | Generates a build.xml file from an InstantMessenger.ecore config file. |
|---|---|
| Meta-models: | CFG = InstantMessenger.ecore XML = XML.ecore |
| Models: | IN = a configuration model such as config.ecore OUT = the output 'build.xml' file |
UML 2 pre-configured versions
Four pre-configured versions of the instant messaging client exist:
| default | The default version of the instant messaging client. Includes the following features / selective refinements / selective tranformation libraries: AWT, Jabber, DefaultJabber, Local / UML2JavaObserver, UML2Applet / JavaMappings, Java1. |
|---|---|
| java2 | The java2 version of the instant messaging client. Includes the following features / selective refinements / selective transformation libraries: AWT, Jabber, DefaultJabber, Local / UML2JavaObserver, UML2Applet / JavaMappings, Java2. |
| swing | The java2/swing version of the instant messaging client. Includes the following features / selective refinements / selective transformation libraries: Swing, Jabber, DefaultJabber, Local / UML2JavaObserver, UML2Applet / JavaMappings, Java2. |
| midp | The MIDP/mobile phone version of the instant messaging client. Includes the following features / selective refinements / selective transformation libraries: LCDUI, Jabber, MEJabber, Local / UML2Observer, UML2MIDlet / JavaMappings, Java1. |
Each of these versions contain a 'build.xml' file in their main project directory that generates a 'build' folder with a 'build.xml' file. That 'build/build.xml' file generates the intermediate models (PSM) and code for that version.
In addition, each of these versions contain a 'packaging' folder that contains 'build.xml' scripts for packaging the generated code in a particular way. The packages are stored in the uml2cs-instantmessenger-model/deployment/data/ folder.
N.B. All 'build.xml' files must be executed in the same JRE as Eclipse:
- Right-click build file
- Select “Run As → 2 Ant Build…”
- Select “Run in the same JRE as the workspace” under the “JRE” tab
UML 1.4 source models
The source consists of several UML 1.4 models, of which one forms the “core” feature (or “concept”). The other models represent optional features that can be merged with the core model using the MergeModel.atl transformation. The source models for this case study can be found here (see also the installation instructions. The models were all developed using the Poseidon CE 3.0.1 CASE tool. The following models (features) are available:
- InstantMessengerModel.xmi
“Core” model, containing the minimal infrastructure of the instant messaging client. - InstantMessengerAWT.xmi
Java AWT user interface. - InstantMessengerSwing.xmi
Java Swing user interface. - InstantMessengerLCDUI.xmi
Java MIDP LCDUI user interface (for mobile phones). - InstantMessengerJabber.xmi
Jabber network protocol support (using the JabberWookie library). - InstantMessengerDefaultJabber.xmi
Jabber default java.net.Socket transport. - InstantMessengerMEJabber.xmi
Jabber MIDP javax.microedition.io.Connection transport. - InstantMessengerLocal.xmi
Local/loopback network protocol support (also used for debug/error messages). - InstantMessengerSMS.xmi
SMS network protocol support (for mobile phones). Currently just a stub/dummy.
UML 1.4 refinement transformations
In addition, a series of refinement model transformations have to be applied before Java code can be generated. These refinement transformations sometimes introduce a part of static model content (doesn't vary based on input model) and always introduce a part of dynamic model content (varies based on input model). The static content is generally merged with the input model using the transformations rules from the MergeModel.atl transformation. The available refinement transformations can be found here.
UML 1.4 pre-configured versions
Four pre-configured versions of the instant messaging client exist:
| default | The default version of the instant messaging client. Includes the following features / refinements: AWT, Jabber, DefaultJabber, Local / AssociationAttributes, Accessors, JavaObserver, Singleton, Applet, DataTypes, AsyncMethods. |
|---|---|
| java2 | The java2 version of the instant messaging client. Includes the following features / refinements: AWT, Jabber, DefaultJabber, Local / Java2AssociationAttributes, Java2Accessors, JavaObserver, Singleton, Applet, Java2DataTypes, AsyncMethods. |
| swing | The Java2/Swing version of the instant messaging client. Includes the following features / refinements: AWT, Swing, Jabber, DefaultJabber, Local / Java2AssociationAttributes, Java2Accessors, JavaObserver, Singleton, Applet, Java2DataTypes, AsyncMethods. |
| midp | The MIDP/mobile phone version of the instant messaging client. Includes the following features / refinements: LCDUI, Jabber, MEJabber, Local, SMS / AssociationAttributes, Accessors, Observer, Singleton, MIDlet, DataTypes, AsyncMethods. |
The source models repository contains an outmodels folder, in which the Ant build.xml files can be found to generate each of these preconfigured versions. Note that these build files and the various Config.atl files need to be adapted for the correct source code path. In addition, a remotebuild example Ant build.xml script has been included to illustrate how model transformation and code generation of several configurations can be offloaded to a remote (multi-processor) machine.
