250 likes | 328 Views
IPSJ SIG-PRO. X-ASB: A Framework for Implementing Extensible AOPL. Naoyasu Ubayashi (Kyushu Institute of Technology) Hidehiko Masuhara (University of Tokyo) Tetsuo Tamai (University of Tokyo) March 18, 2004. Overview. Motivation --Issues on implementing AOPL Masuhara & Kiczales Model
E N D
IPSJ SIG-PRO X-ASB:A Framework forImplementing Extensible AOPL Naoyasu Ubayashi (Kyushu Institute of Technology) Hidehiko Masuhara (University of Tokyo) Tetsuo Tamai (University of Tokyo) March 18, 2004
Overview • Motivation --Issues on implementing AOPL • Masuhara & Kiczales Model • X-ASB: A framework for extending AOPL • Towards reflection • Related work • Conclusion
1. Motivation Issues on implementing AOPL
What is the essence of AOP ? JPM (Join Point Model) ! consists of the join points a means of identifying the join points (pointcut) a means of raising effects at the join points (advice) HyperJ? AspectJ? Demeter?
However … • Each of current AOP languages is based on a few fixed set of join point models. • Many different join point models have been proposed, and they are still evolving so that they could better modularize various crosscutting concerns. • There are crosscutting concerns that may not be modularized with current join point models.
Example AspectJ Demeter aspect DisplayUpdating { pointcut move(FigureElement figElt): target(figElt) && (call(void FigureElement.moveBy(int, int)) || call(void Line.set*(Point)) || call(void Point.set*(int))) after(FigureElement fe) returning:move(fe){ Display.update(fe); } } class Company { static ClassGraph cg = new ClassGraph(); // class structure Double sumSalaries() { String s =''from Company to Salary''; // traversal strategy Visitor v = new Visitor(){ // adaptive visitor private double sum; public void start() { sum = 0.0;} public void before(Salary host) { sum += host.getValue();} public Object getReturnValue() { return new Double(sum);} }; return (Double)cg.traverse(this, s, v); } // ... rest of Company definition ... } drastically different
Extensible AOPLs are needed! Our Final Goal computational reflection for AOP Initial Result -- Common implementation model for JPMs We propose a framework for implementing extensible AOPLs in which different JPMs can be provided as its extension.
Weaving process • parses source code, and creates an internal data structure including an AST (Abstract Syntax Tree) in AspectJ, an object graph in Demeter, and so forth. • analyzes the internal data structure, creates a join point, checks if the join point satisfies conditions specified by pointcut designators, and execute advice if these conditions are true.
Masuhara & Kiczales model(1) M & K (Masuhara & Kiczales) Model [ECOOP 2003] common framework for modeling different join point models including PA (pointcuts and advice as in), TRAV (traversal specifications as in Demeter), COMPOSITOR (class hierarchy composition as in Hyper/J), OC (open classes as in AspectJ), and QB (query-based browsing as in JQuery)
EFFB - means ofeffecting B - program EFFA IDB IDA- means ofidentifying META -weavingparameter X - computation or program XJP- join point Masuhara & Kiczales model(2) <X, XJP, A, AID, AEFF, B, BID, BEFF, META>
Development process 1. define kindsof join points 2. define kinds of pointcuts 3. define a body of a weaver define computation at pointcuts X-ASB overview (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))))
Advantage- modular JPM extension - • Hot spots for adding new kinds of join points and pointcut constructs are better modularized in comparison with the original ASB implementation. (encapsulated in the code region for the framework adaptation) • In ASB, the code for adding them is scattered in several code regions.
4. Towards reflection --- Future work ---
Reflective features of 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))) extend PA weaver (class sample-calling-sequence object (method void register-user-defined-pcd () (meta register-one-pcd 'calling-sequence-pcd-check? 'calling-sequence-pcd-handler) (super register-user-defined-pcd)) (method boolean calling-sequence-pcd-check? ((pcd p)(jp j)) ...) (method void calling-sequence-pcd-handler ((pcd p)(jp j)) ...))
A big problem • Although JPMs such as COMPOSITOR need compile-time weaving, JPMs such as TRAV need run-time weaving. PA can be implemented by either of them. • We must integrate compile-time weaving and run-time weaving into a single interpreter.
Example (jpm 'pa 'static) (jpm 'trav 'dynamic) (jpm 'compositor 'static) (jpm-precedence 'compositor 'pa 'trav) ;; COMPOSITOR (class foo object (method void init () (super init)) (method void test () (write 'foo) (newline))) (class bar object (method void init () (super init)) (method void test () (write 'bar) (newline))) (class main user-defined-jpm (method void main () (send (new foo) test)) ;pointcut & advice for compositor (pcd 'compositor 'merge-foo-and-bar '(foo NL bar NL)) (advice 'compositor 'merge-foo-and-bar 'merge-by-name)) ;; PA (class sample-fact user-defined-jpm (method int main () (send this fact 6)) (method int fact ((int n)) (if (< n 1) 1 (* n (send this fact (- n 1))))) (method void write-after () ...) ;pointcut & advice (pcd 'pa 'call-fact '(call fact)) (advice 'pa 'call-fact '(after 'write-after)))
Related Work • XAspect • CME (Concern Manipulation Environment) • Josh
Summary • We proposed X-ASB, a framework for implementing extensible AOPLs. • The framework exposes programming interfaces for adding new kinds of JPMs. • Clarifying programming interfaces for extending JPMs is an important milestone towards computational reflection for AOP.