Title: Generating Aspect Code from Models
1Generating Aspect Code from Models
1Jeff Gray, 2Ted Bapty, 2Sandeep Neema,
2Aniruddha Gokhale, 2Balachandran
Natarajan 1University of Alabama at Birmingham
(UAB) 2Vanderbilt University/ISIS
- OOPSLA 2002 Workshop on Generative Techniques in
the Context of the MDA - November 5th, 2002
- Seattle, WA
- This work is supported by the DARPA IXO, under
the Program Composition for Embedded Systems
(PCES) program, Contract Number F33615-00-C-1695
2An argument for generating aspect code from models
- Often, generators have knowledge of pre-existing
libraries of components - Generation of glue code (high reuse) vs.
generation of whole system (little reuse) - If not originally templatized, component library
can become closed to modification during
generation - Granularity of reuse at the interface level
internal implementation of method bodies not open
for change - Customizing the component to monitor/adapt to QoS
requirements specified in the model may not be
possible - An AOP approach could offer some benefit, whereby
the points of customization are weaved into
library components
3Concretizing aspects
AspectJ
Generated Concrete Aspects
4Component modeling in GME
5Two levels of weaving
Aspect Model Weaving
Aspect Code Weaving
6Abstract Component
public abstract class Component public
abstract void call_back() public abstract int
get_data() public abstract void init()
public abstract void data_retrieve() public
abstract void compute() public abstract void
notify_availability() protected int _data
7Stubbed LocDisplay library component
public class LocDisplay extends Component
public void call_back() System.out.println("T
his was LocDisplay.call_back") public int
get_data() return _data public void
init() public void data_retrieve()
System.out.println("This is LocDisplay.data_retrie
ve!") UpdateMap map new UpdateMap()
map.get_data() public void compute()
System.out.println("This is LocDisplay.compute!"
) public void notify_availability()
System.out.println("This is LocDisplay.notify_avai
lability!")
8Lazy abstract library aspect
abstract aspect Lazy abstract pointcut
call_back(Component c) abstract pointcut
get_data(Component c) after(Component
c) call_back(c) System.out.println("aft
ercall_back (Lazy)!") c.notify_availabilit
y() before(Component c)
get_data(c) System.out.println("beforeg
et_data (Lazy)!") c.data_retrieve()
c.compute()
9Generated code for concrete aspect
aspect LocDisplayLazy extends Lazy
pointcut call_back(Component c) this(c)
executions(void LocDisplay.call_back(..))
pointcut get_data(Component c) this(c)
executions(int
LocDisplay.get_data(..))