Aspect Oriented Code Generation in oAW 4
I have for a long time advocated the combination of model-driven
and aspect oriented approaches to software development. FOr example,
in my patterns paper on this topic I have shown an approach of using
AO techniques on the level of code generation templates. As of version
4, the openArchitectureWare MDSD framework now supports aspects on
code generation templates.
Assume you have a code generation template that generates some
kind of implementation code for a data entity:
«DEFINE Entity FOR data::Entity»
«FILE baseClassFileName() »
public abstract class «baseClassName()» {
«EXPAND Impl»
}
«ENDFILE»
«ENDDEFINE»
«DEFINE Impl FOR data::Entity»
«EXPAND GettersAndSetters»
«ENDDEFINE»
Now assume, that from somewhere else (we call this a different
cartridge, or generator module) you want to add additional code
to the body of the generated class, after the getters and setters ...
and all of this
without modifying the original generator templates.
Here's what you can do in oAW 4. The example adds "meta information" to the
generated class (just an example ...).
«AROUND Impl FOR data::Entity»
«targetDef.proceed()»
«FOREACH attribute AS a»
public static final AttrInfo «a.name»Info =
new AttrInfo( "«a.name»", «a.type».class );
«ENDFOREACH»
«ENDAROUND»
Now isn't this cool?
After having this feature in code generation templates, the next step would
be to add this to model-to-model transformations.
Does anybody know anybody who does this already? I would be interested.