AndroMDA Samples

AndroMDA would be very difficult to grasp without at least one sample application. Therefore, the distribution includes several:

Where can I find the samples?

The models and source code of each sample are located within the samples directory of the AndroMDA binary and source distributions.

How are the samples structured?

The src directory of each module described below (excluding the mda module which is a special case) contains the sources that have been hand coded, most of them were generated by AndroMDA the first run and then they had business or custom logic hand-coded in.

Each sample is made up of the modules explained here:

  • /mda

    This is the most important module, as it contains the project's model. This module is used by AndroMDA to generate code into all other modules.

    What happens within this module is this:

    1. maven calls the andromda:run goal of the AndroMDA maven plugin
    2. The plugin tells AndroMDA to load the model located in the mda/src/uml.
    3. The AndroMDA plugins (cartridges, and translation-libraries) declared within the mda/project.xml file let AndroMDA know exactly what stuff it needs to generate when processing the model.
    4. AndroMDA runs and the files/resources are generated to the locations defined by the namespace properties within the plugin dependencies.
    5. Make sure to also check out the conf/andromda.xml file, which configures AndroMDA and its components.
  • /app

    Contains files required to create the ear bundle. Typically you will find application deployment descriptors in this directory, as well as DDL scripts to initialize/drop your schema (if you're using hibernate/spring).

  • /common

    Contains common sources that can be shared between the different modules in the project. Typically you will find utility classes in this directory.

  • /core

    Contains the persistence and business/transaction management layer. This contains generated source from either the hibernate, spring, or ejb cartridges.

  • /web

    Contains sources required to build the presentation layer.

  • /webservice

    Contains any source, descriptors, or other necessary files required for webservice support.

How do I build the samples?

Its very easy to build all samples or just one at a time. First of all you MUST install Maven2. To build all, just change to the samples directory, and type mvn. To build a single sample (i.e. animal-quiz), just change to the samples/animal-quiz directory and again type maven. That's all there is too it!

After the build of a sample completes, you'll notice each module contains a target directory, this target directory contains all generated source, any class files, any generated descriptors, etc. (i.e. anything that has been generated/created during the build process which will NOT be checked into source control).

Once built, you'll find each deployable ear file located in the /app/target directory. Each ear can deployed by dropping it in the deploy directory of a JBoss application server instance.

Need more help?

In case of difficulties, please view the forum at http://forum.andromda.org and post your questions there.