Implementation Issues
This section describes some implementation details of the model to Java transformation. The transformation is template based using Eclipse's Java Emitter Templates (JET) technology. The second important technology that allowed to develop this particular transformation and integrated it into the RSM environment is the Eclipse Plug-in development environment.
Transformation Templates
The code part of a model to source transformation are Java Emitter Templates (JET). Only three JET files were necessary for the transformation of UML2 models to Java source code. One JET file was needed for transforming of a UML class element and an associated state machine, the second one for transforming of a UML interface element, and the third one for a transformation of enumerations. All three JET files are part of the downloadable code generation plug-in for RSM.
Helper Class
Although the whole transformation process can be implemented only by means of JETs, the experience has shown that such solution is not very practical. The main reason is maintainability, even a simple JET file is not easily readable and understandable. Therefore a helper class that performs more complicated queries to the processed model had to be introduced and integrated into the JET files for class and interface transformation. The helper class, UML2JavaGenerationHelper, provides a set of APIs that facilitate retrieving specific information from the model. Note that the UML2JavaGenerationHelper class can be easily reused for a different type of transformation if the target language is Java. The class can be found in the ch.ethz.codegen.modeler.uml2java.util package.