This article shows you how to write an AndroMDA cartridge in 10 distinct steps, using a sample cartridge which generates an Ant-like build script from a UML deployment model. This is why the tutorial cartridge is called "andromda-deployment".
Now, the next question is: If I know my PIM (platform independent model) and my PSM (platform specific model), then how do I transform PIM elements to PSM elements and to code? Think of this in two steps:
When you find the transformation rules for your cartridge, record them as a table on a piece of paper. In the case of our deployment sample, you might want to record the following transformation rules:
Source element in PIM | Target elements in PSM | Transformation |
Node | Project | one project for each node in the system |
Node | Target | one "compile" and one "deploy" target per node which contain all tasks for all artifacts and packages of this node |
Artifact | Task | one <jar> task for each artifact |
Package | Task | one <javac> task for each package |
Now, think of a transformation rule as an operation inside a PIM metafacade. Let those operations return PSM metaobjects. The algorithm inside the operation implements the PIM-to-PSM transformation.
Design the transformation rules you have found as methods of one or more metafacade classes. Then apply the three-step process: