an aop implementation framework for extending join point models

23
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-Data for Software Evolution

Upload: brock-diaz

Post on 30-Dec-2015

37 views

Category:

Documents


3 download

DESCRIPTION

ECOOP 2004 Workshop on Reflection, AOP and Meta-Data for Software Evolution. RAM-SE’04. An AOP Implementation Framework for Extending Join Point Models. Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Hidehiko Masuhara(University of Tokyo, Japan) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: An AOP Implementation Framework for Extending Join Point Models

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

Page 2: An AOP Implementation Framework for Extending Join Point Models

2

Overview

1. Motivation-- Join Point Model evolution

2. MOPs for Join Point Model extensions3. Towards reflection for AOP4. Related work5. Conclusion

Page 3: An AOP Implementation Framework for Extending Join Point Models

3

1. Motivation

Page 4: An AOP Implementation Framework for Extending Join Point Models

4

Software evolution in AOP

AOP is effective in unanticipated software evolution because crosscutting concerns can be added or removed without making invasive modifications to original programs.

coreconcerns

added

removed

coreconcerns

coreconcerns

concernspace

evolution

crosscuttingconcerns

Page 5: An AOP Implementation Framework for Extending Join Point Models

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

Page 6: An AOP Implementation Framework for Extending Join Point Models

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…

Page 7: An AOP Implementation Framework for Extending Join Point Models

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.

Page 8: An AOP Implementation Framework for Extending Join Point Models

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()

Page 9: An AOP Implementation Framework for Extending Join Point Models

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.

But, we cannot add a new pointcutbecause we cannot extend AspectJ JPM.

Page 10: An AOP Implementation Framework for Extending Join Point Models

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.

Page 11: An AOP Implementation Framework for Extending Join Point Models

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.

Page 12: An AOP Implementation Framework for Extending Join Point Models

12

2. MOPs for Join Point Model extensions

Page 13: An AOP Implementation Framework for Extending Join Point Models

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

IDBIDB

EFFA

EFFA

EFF B -

mea

ns of

effe

ctin

g

EFF B -

mea

ns of

effe

ctin

g

META -weaving

parameter

register-pcd

register-jp

AOP Language Model

Masuhara & Kiczales model [ECOOP 2003]

<X, XJP, A, AID, AEFF, B, BID, BEFF, META>

Page 14: An AOP Implementation Framework for Extending Join Point Models

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

Page 15: An AOP Implementation Framework for Extending Join Point Models

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))))

Page 16: An AOP Implementation Framework for Extending Join Point Models

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

Page 17: An AOP Implementation Framework for Extending Join Point Models

17

3. Towards reflection for AOP

Page 18: An AOP Implementation Framework for Extending Join Point Models

18

Evolution of JPMs

Evolution 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.

Page 19: An AOP Implementation Framework for Extending Join Point Models

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

Page 20: An AOP Implementation Framework for Extending Join Point Models

20

4. Related Work

Page 21: An AOP Implementation Framework for Extending Join Point Models

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.

Page 22: An AOP Implementation Framework for Extending Join Point Models

22

5. Conclusion

Page 23: An AOP Implementation Framework for Extending Join Point Models

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.