1
An AOP Implementation Framework for Extending Join Point Models
Naoyasu Ubayashi (Kyushu Institute of Technology, Japan)Hidehiko Masuhara (University of Tokyo, Japan)Tetsuo Tamai (University of Tokyo, Japan)
June 15, 2004
RAM-SE’04 ECOOP 2004 Workshop on Reflection, AOP and Meta-Datafor Software Evolution
2
Overview
1. Motivation-- Join Point Model evolution
2. MOPs for Join Point Model extensions3. Towards reflection for AOP4. Related work5. Conclusion
3
1. Motivation
4
Software evolution in AOPAOP is effective in unanticipated software evolution because crosscutting concerns can be added or removed without making invasive modifications to original programs.
coreconcerns
addedremoved
coreconcerns
coreconcerns
concernspace
evolution
crosscuttingconcerns
5
But, …Software evolution would be restricted if new crosscutting concerns cannot be described with the existing JPMs (join point models).
coreconcerns
new type of crosscutting concernscannot be added
coreconcerns
coreconcerns
concernspace
evolution
crosscuttingconcerns
6
JPM --- Essence of AOPJoin pointsMeans of identifying the join points (pointcut)Means of raising effects at the join points (advice)
an existing structure in which points of interest
are scattered
structure is flattened to stream of
points
points are regrouped
groups form the basis for specifying
some crosscutting semantics
what are join points
means of identifying…
means of specifying
semantics at…
7
When do we need new kinds of JPMs? We want to extend the existing JPMs
slightly in order to adapt to application-specific purposes.
We want to use more than one JPM simultaneously.
8
Motivating example
aspect ProtocolCheck { pointcut someProtocol(): call(void *.someMethod*()) ; before() : someProtocol() { code for logging }}
Version 1
classA
someMethodA()aspect ProtocolCheck
AspectJ JPM
classB
someMethodB()
classC
someMethodC()
9
Motivating example (cont.)
aspect ProtocolCheck { pointcut someProtocol(): call(void *.someMethod*()) ; before() : someProtocol() { code for logging }
pointcut someProtocolError(): !calling-sequence(void *.{someMethodA(), someMethodB(), someMethodC()}) ; before() : someProtocolError() { code for error handling }}
Version 2 AspectJ JPM
classA
someMethodA()aspect ProtocolCheck
classB
someMethodB()
classC
someMethodC()
we want to add a checking for calling sequence(someMethodA -> someMethodB -> someMethodC)
But, we cannot add a new pointcutbecause we cannot extend AspectJ JPM.
10
Current AOP languages … Each of current AOP languages is based
on a few fixed set of JPMs. Many different JPMs have been proposed,
and they are still evolving so that they better modularize various crosscutting concerns.
There are crosscutting concerns that may not be modularized with current JPMs.
11
Our research Goal: Computational Reflection for AOP
Base level(program based on JPM)
Meta level(implementation of
JPM)reify
reflect
MOPsfor JPM extensions
This talk focuses on MOPs for JPM extensions (our initial result).We developed X-ASB (eXtensible Aspect Sand Box) , a framework for rapid-prototyping new JPMs.
12
2. MOPs for Join Point Model extensions
13
eval-program
MOPs for JPM extensions
[Program execution model]policy of program execution (AspectJ-like policy, traversal policy, etc.)
[Join point model]join pointpointcut (evaluator for selecting join point)advice (computation at a join point)
lookup-A-IDlookup-B-IDeffect-A A-IDeffect-B B-ID
MOP
B - program
X - computationor program
XJP- join
point
IDA -
means of
identifying
ID B
EFFA
EFF B -
means o
f
effec
ting
META -weaving
parameter
register-pcd
register-jp
AOP Language Model
Masuhara & Kiczales model [ECOOP 2003]
<X, XJP, A, AID, AEFF, B, BID, BEFF, META>
14
Steps for modular weaver construction Step 1: define kinds of join points Step 2: define kinds of pointcuts Step 3: define a body of weaver, and
computation at join points
15
Construction of AspectJ-like weaver
eval-program
register-jp
register-pcd
lookup-A-ID
lookup-B-ID
effect-A
effect-B
call-methodjoin point
programexecution tree
weaver
MOPs Weaver [written in Scheme](define weaver (lambda (pgm meta) (register-jp) (register-pcd) (eval-program pgm meta)))Step 1: define kinds of join points(define register-jp (lambda () (register-one-jp 'call-method generate-call-jp)))
Step 2: define kinds of pointcuts(define register-pcd (lambda () (register-one-pcd 'call call-pcd?)))
Step 3: define a body of weaver, and computation at join points(define call-method (lambda (mname obj args) (computation-at-jp ((lookup-jp-generator 'call-method) mname obj args) null)))
(define computation-at-jp (lambda (jp param) (let* ((A-ID (lookup-A-ID jp param)) (B-ID (lookup-B-ID jp param))) (effect-B B-ID jp (lambda () (effect-A A-ID jp param)) param))))
16
Extension of AspectJ-like weaver
(define register-pcd (lambda () (register-one-pcd 'calling-sequence calling-sequence-pcd?)))
A new pointcut designator (calling-sequence) can be added to AspectJ-like weaver
eval-program
register-jp
register-pcd
lookup-A-ID
lookup-B-ID
effect-A
effect-B
call-methodjoin point
programexecution tree
weaver
MOPs
17
3. Towards reflection for AOP
18
Evolution of JPMsEvolution by language developers
Evolution by application developers
The effectiveness in software evolution would be restricted if language developers must extend JPMs whenever application programmers need new kinds of JPMs.
Reflection for AOP
It would be better for application programmers to be ableto add new JPMs using MOPs within the base language.
19
Reflection in X-ASB
(class sample-protocol-error-detection object (method int m1 () (...)) (method int m2 () (...)) (method int m2 () (...)) (after (calling-sequence (not (list 'm1 'm2 'm3))) (write 'invalid-calling-sequence) (newline)))
(class sample-calling-sequence object (method void register-pcd () (meta register-one-pcd 'calling-sequence 'calling-sequence-pcd?) (super register-pcd))
(method boolean calling-sequence-pcd? ...))
Scheme-based language
Base level
Meta level
--- power of reflection is still limited
20
4. Related Work
21
Related Work XAspect [Shonle, Lieberherr, and Shah, 2003]:
extensible domain-specific AOP language that adopts plug-in mechanisms. Adding a new plug-in module, we can use a new kind of aspect-oriented facility.
Josh [Chiba and Nakagawa, 2004]: open weaver that can define a new pointcut construct as a boolean function.
Using X-ASB, we can add not only new pointcut constructs but also new kinds of join points and advice.
22
5. Conclusion
23
Conclusion
We proposed mechanisms for extending JPMs in order to support unanticipated software evolution.
Using X-ASB, we can introduce new kinds of JPMs when we face new kinds of crosscutting concerns that cannot be handled by existing JPMs.