University of Alabama at Birmingham

GenAWeave: A Generic Model-Driven Aspect Weaver Framework

Inria Logo NSF Logo Softcom Logo


This work presents an approach that combines metamodeling with program transformation techniques to construct aspect weavers for general-purpose programming languages (GPLs). The front-end of the weaver framework is used to specify aspects for GPLs and is designed with a metamodel-based approach using the AMMA toolsuite. The back-end uses an existing program transformation engine (DMS) to weave aspects into target programs. Both the aspect specification and transformation rules are captured as models within the AMMA platform.The translation from source aspect model to target transformation model is achieved using ATL, which is a model transformation language in AMMA. This work has been done in collaboration between UAB SoftCom Lab in Birmingham, Alabama (USA) and the ATLAS Group in Nantes, France.

Keywords

Model-Driven Engineering, Aspect-Oriented-Programming, Program Transformation. .

Overview

Program transformation systems have been used in the past to construct aspect weavers for programming languages. Program transformation engines (PTEs) such as the Design Maintenance System (DMS), or ASF+SDF, provide direct availability of scalable parsers and an underlying low-level transformation framework to modify source programs. However, due to the accidental complexities and the associated skill-sets needed to use a PTE, such tools are generally accessible only by language researchers, not general software developers.

The main objective of this research is to combine metamodeling approaches with transformation systems to investigate how model engineering can assist in constructing aspect weavers for general-purpose programming languages (GPLs). The approach eliminates the accidental complexities associated with PTEs, but still leverages the power of such systems. The architecture can be divided into two layers. The front-end uses an aspect-like language similar to AspectJ, which is then translated (using ATL) to lower-order transformation rules used by the back-end (e.g., the DMS Rule Specification Language - RSL). The generated transformation rules are then processed by DMS to weave aspects into a source program. The following figures illustrates this mechanism.


Overview of model-driven aspect weaver framework

In this work, we demonstrate the usage of two different aspect languages (namely AspectPascal and AspectFORTRAN). The metamodels for both AspectPascal and AspectFORTRAN share a common abstract core (GAspect). The following figures show the metamodels for AspectPascal and AspectFORTRAN respectively. The part beneath the dotted rectangle shows the commonality between these metamodels.


AspectPascal Metamodel


AspectFORTRAN Metamodel

The core elements for designing a metamodel for an aspect language are join points, pointcuts and advice. Join points are execution points of a program, such as a method invocation or a particular exception being thrown. Pointcuts are means of identifying a set of join points through a predicate expression. Advice defines actions to be performed when a particular join point is reached. The metamodel is implemented internally using KM3 and TCS. KM3 is a metamodeling language available in AMMA and is used to specify the abstract syntax of the metamodel. TCS is also available within the AMMA toolsuite and is used to specify the concrete syntax (grammar) of the metamodel. The complete KM3 and TCS specification for AspectPascal and AspectFORTRAN is hyperlinked below. A simple comparison between the metamodels of these two languages will show the commonality between them, especially in terms of the GAspect.

[AspectPascal KM3 spec]    [AspectPascal TCS spec]    [AspectFORTRAN KM3 spec]    [AspectFORTRAN TCS spec]   

The target model conforms to the DMS Rule Specification Language (RSL) which provides basic primitives for describing numerous transformations that are to be performed across the entire code base of an application. The RSL consists of declarations of patterns, rules, conditions, and rule sets using the external form (concrete syntax) defined by a language domain. Patterns describe the form of a syntax tree. They are used for matching purposes to find a syntax tree having a specified structure. Patterns are often used on the right-hand side (target) of a rule to describe the resulting syntax tree after a transformation rule is applied. The RSL rules describe a directed pair of corresponding syntax trees. A rule is typically used as a rewrite specification that maps from a left-hand side (source) syntax tree expression to a right-hand side (target) syntax tree expression. Rules can be combined into sets of rules that together form a transformation strategy by defining a collection of transformations that can be applied to a syntax tree. The patterns and rules can have associated conditions that describe restrictions on when a pattern legally matches a syntax tree, or when a rule is applicable on a syntax tree. The following diagram specifies a snippet of the Rsl Metamodel and its KM3 specification.



RSL metamodel excerpt

The RSL Metamodel contains various elements like patterns, conditions, rules and rule sets. The complete RSL metamodel specification (KM3 and TCS) is available as follows: [RSL KM3 spec]    [RSL TCS spec]. The complete scenario describing how a source aspect specification is transformed to a target RSL specification is shown below. The ATL transformation language is used to do the translation from source aspect to target RSL.The following case studies will provide more details about ATL specifications and the underlying models derived from the source and target metamodels.



Transformation Overview

Case Studies

In order to experiment with the approach presented here, we constructed two aspect weavers – one for Object Pascal and another for FORTRAN using our generic model-driven framework. A subset (e.g., primitive pointcuts like call, execution, loop) of standard AOP features was built into both of the weavers. The FORTRAN weaver was constructed after the completion of the AspectPascal weaver and reused several functionalities, code and knowledge from the previous construction without much alteration to the core artifacts. For example, both weavers shared the generic front-end, which constituted around 50% of the overall front-end LOC (written in KM3 and TCS). Moreover, the FORTRAN weaver could reuse 30% of the Object Pascal rule generator code without any alteration, and another 25% with minor customization (See comparisons of ATL specifications for FORTRAN and ObjectPascal weavers below). Most of the time and effort on building the FORTRAN weaver was spent on understanding the concrete syntax of the language and on the conceptual design of the weaver.The following links provide all the generated artifacts, examples, complete source code of each of the individual weavers.

AspectPascal Weaver          AspectFORTRAN Weaver

Comparisons of Rule Generator Code (Reusability)

The comparison between the rule generator code (higher-order ATL transformations) for both AspectPascal and AspectFORTRAN weavers are shown below. The first link shows the comparitive difference between the ATL transformations for translating a function / procedure call join point and function / subroutine call join point in ObjectPascal and FORTRAN respectively. The second link shows the comparitive difference between the ATL transformations for translating a loop execution join point defined in ObjectPascal and FORTRAN respectively. The results visually demonstrate the level of reuse among the rule generators for constructing weavers for these two languages.

Difference in ATL transformations for translating call join point in FORTRAN and ObjectPascal

Difference in ATL transformations for translating loop execution join point in FORTRAN and ObjectPascal




Reusabilty Summary

References

[1] Gray, J, and Roychoudhury, S, "A Technique for Constructing Aspect Weavers using a Program Transformation Engine," AOSD ’04, International Conference on Aspect-Oriented Software Development, Lancaster, UK, March 22-26 , 2004, pp. 36-45

[2] Roychoudhury, S, Gray, J, and Jouault, F, "A Model-Driven Framework for Aspect Weaver Construction," submitted to Transactions of Aspect-Oriented Software Developments, Special Issue on Aspects and MDE.

[3] Baxter, I, Pidgeon, C, and Mehlich, M, "DMS: Program Transformation for Practical Scalable Software Evolution," International Conference on Software Engineering (ICSE), Edinburgh, Scotland, May 2004, pp. 625-634.

[4] Jouault, F, and Bézivin, J, "KM3: a DSL for Metamodel Specification," 8th IFIP International Conference on Formal Methods for Open Object-Based Distributed Systems, LNCS, Bologna, Italy, pp. 171-185.

[5] Jouault, F, Bézivin, J, and Kurtev, I, "TCS: a DSL for the Specification of Textual Concrete Syntaxes in Model Engineering," International Conference on Generative Programming and Component Engineering, Portland, Oregon, USA, Oct 2006, pp. 249-254

[6] Jouault, F, and Kurtev, I, "Transforming Models with ATL," Model Transformations in Practice Workshop at MoDELS 2005, Montego Bay, Jamaica

Download

AspectPascal Compiler

ANT scripts to run the AspectPascal compiler

AspectFORTRAN Compiler

ANT scripts to run the AspectFORTRAN compiler

Complete Source

Full source code for AspectPascal and AspectFORTRAN weavers including sample test files. Also contains C++ and Java metamodels (Aspect Extensions)

GenAWeave Video Demos

Video 1:
The following video demonstrates the Aspect Pascal (Borland's Delphi) weaver that was built using the GenAWeave Framework. It shows an example where a particular cross-cutting concern (persistence during language internationalization) is identified. The demo shows the KM3, TCS, and ATL specification along with the generated RSL used as input to DMS program transformation engine. The entire weaver is automated using ANT scripts and shows how higher-order aspect language is translated to lower-order transformation rules.

Video 2:
The following video demonstrates the Aspect FORTRAN weaver that was built using the GenAWeave Framework. It shows an example where cross-cutting concerns related to loop-execution join points (do loop in case of FORTRAN) can be specified. The demo shows the KM3, TCS, and ATL specification of the Aspect FORTRAN weaver along with the generated RSL used as input to DMS program transformation engine.

Video 3:
The following video demonstrates the inner workings of our initial ObjectPascal (Borland's Delphi) aspect weaver that was built directly using DMS and without a MDE approach. In general, it shows an example where a particular cross-cutting concern (a dirty-bit) is identified in over 20 redundant locations. The demo shows the various locations where the dirty-bit concern is located. The dirty-bit is then manually removed from the source and then automatically weaved in using lower-order transformation rules written in DMS. It was one of our initial efforts that used RSL rules directly to do weaving. The current model-driven technique however generates these RSL rules from the aspect-language directly.

**NOTE: You may need to install the Camtasia co-dec to view the AVI format. It is located at:

     http://www.techsmith.com/products/studio/codec.asp

If you have any problems with these videos, or would like to see them in a different video format, please write to me

Acknowledgement

This work is supported in part by an NSF CAREER award (CCF-0643725) and by the OpenEmbeDD project.

General Information

@Copyright 2008 - All Rights Reserved

Any information provided in this web page is copyright by the persons mentioned above, also any source available for download is provided "as is" and any express or implied warranties are disclaimed

Disclaimer for official UAB web pages