ITWissen.info - Tech know how online

AndroMDA

AndroMDA (pronounced Andromeda) is a framework for generating program code based on Model Driven Architecture (MDA). MDA is the basic standard for generative development of software, which was specified by the Object Management Group (OMG) in June 2003. MDA implements a specification that is independent of specific technologies and can be used for the automatic generation of program code on various platforms such as J2EE, .NET or CORBA.

In addition to AndroMDA, the OpenArchitecture-Ware framework, which is also available as open source, implements the OMG's MDA specification. AndroMDA was developed on the basis of the code generator UML2EJB by Matthias Bohlen and a large open source community - also called the AndroMDA team. The background to the development of AndroMDA was to be able to generate the corresponding program code directly on the basis of static and dynamic UML models. Cartridges are used to process the elements of the AndroMDA meta-models in order to generate the program code fragments. Currently, cartridges are available for Java, C#, JSF (JavaServer Faces), XmlSchema and Hibernate, among others. The framework also supports the realization of application-specific cartridges. The generation of program code for different target languages is controlled by templates, so that, for example, implementations for HTML or PHP can also be realized. For the creation of the UML models, AndroMDA is dependent on an external tool for modeling. However, from AndroMDA's point of view, the necessary requirements are met by a number of available modeling tools. Thus, redundant standard tasks - which are often a significant part of specific applications - can be automated with AndroMDA. In this context, users report code generation rates of over 50%.

Construction kit with different tools

AndroMDA is implemented as a comprehensive construction kit with different tools for generating program code within a complex framework.

Components of AndroMDA

Components of AndroMDA

The figure therefore first shows the various components of AndroMDA, the most important of which are briefly explained below.

For the use of AndroMDA an external UML modeling tool is required, which in any case must support the export of XML MetaData Interchange (XMI) files - in this format the created UML models are stored. Furthermore, it should be possible to create class diagrams, activity diagrams, UML Tagged Values and UML Constraints (OCL). One such example for the implementation of the mentioned requirements is the modeling tool MagicDraw, which is freely available in limited functionality at the link below.

As the figure shows, the entire framework is controlled by the Mavenplug-in, the foundations of which were created in the ApacheAnt project. Maven is a build management tool implemented in Java that takes a model-based, declarative approach to implementing the build process. This also greatly simplifies the implementation process.

Central components of AndroMDA

The MetaData repository takes care of reading the XMI file and mapping the UML model as an instantiated metamodel in memory, instantiating a separate Java object for each model element. These objects are accessed via the Java Metadata Interface(JMI) API, providing the basis for further transformations.

Cartridges are the central component of code generation and consist of JAR archives with templates, metafacades and descriptors. Cartridges allow the processing of model elements that are marked with stereotypes or whose dependency results from certain conditions. Cartridges are available for BPM4Struts, jBPM, JSF, EJB, Hibernate, Java, Meta, Spring, Webservice or XmlSchema. The creation of additional cartridges for individual needs is possible. The code to be generated is specified by the templates, which can be defined in the cartridge descriptor.

Metafacades (derived from: Metamodel Facades) provide access to the model objects of the MetaData repository and are based on the software design pattern Facades. This hides the complexity of the JMI behind simple interface classes. In addition, the metafacades perform other tasks such as validating the metamodel or implementing the translation libraries and datatype mappings. The templates are used to access the methods of the metafacade classes.

The template engine supports the processing of the templates, whereby AndroMDA offers the use of two possible engines - Freemarker and Velocity.

How the Velocity Template Engine works

How the Velocity Template Engine works

The basic functionality of a template engine is demonstrated by the Velocity template engine shown in the figure. More information on the template engines mentioned is available at the link below.

The translation libraries enable the processing of expressions in Object Constraint Language (OCL) for queries to a database, for example. Finally, the Datatype Mappings translate the data types of the model into the target language specified in the descriptor.

In summary, the functionality of AndroMDA results from the following steps:

  • Transferring a UML model in XMI format,
  • Reading the XMI file from the repository component,
  • mapping in memory as an instantiated UML metamodel based on Java objects,
  • access via metafacades and templates of a cartridge,
  • control of code generation by template engine.

Informationen zum Artikel
Englisch: AndroMDA
Updated at: 28.10.2013
#Words: 1403
Links:
Translations: DE