1 / 33

An Aspect-oriented Weaving Mechanism Based on Component-and-Connector Architecture

An Aspect-oriented Weaving Mechanism Based on Component-and-Connector Architecture. Naoyasu Ubayashi (Kyushu Institute of Technology ) February 12, 2008.

talen
Download Presentation

An Aspect-oriented Weaving Mechanism Based on Component-and-Connector Architecture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An Aspect-oriented Weaving Mechanism Based on Component-and-ConnectorArchitecture NaoyasuUbayashi (Kyushu Institute of Technology) February 12, 2008 NaoyasuUbayashi, Akihiro Sakai, and Tetsuo Tamai, “An Aspect-oriented Weaving Mechanism Based on Component-and-Connector Architecture”, In ASE’07, pp.154-163

  2. POSL Research Group • Aspect-oriented programming • Reflection • Coordination language • Modeling language • Architecture description language (ADL) • Domain-specific language (DSL) • Formal methods Principles of Software Languages http://posl.minnie.ai.kyutech.ac.jp/

  3. Recent publications • CAiSE 2009 (21st International Conference on Advanced Information Systems) • NaoyasuUbayashi, GenyaOtsubo, Kazuhide Noda, and Jun Yoshida: An Extensible Aspect-oriented Modeling Environment (to appear). • ICST 2008 (1st IEEE International Conference on Software Testing, Verification, and Validation) • NaoyasuUbayashi, JinjiPiao, SuguruShinotsuka, and Tetsuo Tamai: Contract-based Verification for Aspect-oriented Refactoring. • ASE 2007 (22nd IEEE/ACM International Conference on Automated Software Engineering) • NaoyasuUbayashi, Akihiro Sakai, and Tetsuo Tamai: An Aspect-oriented Weaving Mechanism Based on Component-and-Connector Architecture. • ASE 2005 (20th IEEE/ACM International Conference on Automated Software Engineering) • NaoyasuUbayashi, Genki Moriyama, Hidehiko Masuhara, and Tetsuo Tamai: A Parameterized Interpreter for Modeling Different AOP Mechanisms. • ICSE 2005 (27th IEEE/ACM International Conference on Software Engineering) • Tetsuo Tamai, NaoyasuUbayashi, and Ryoichi Ichiyama: An Adaptive Object Model with Dynamic Role Binding.

  4. My talk • ASE’07 + Current work

  5. Aspect-oriented Programming Problem A concern considered crosscutting in one situation might be primary in others. It is not desirable to fix a certain concern as either primary or crosscutting. It is not easy to understand software architecture (the overall behavior of a woven program). AOP is a programming paradigm in which crosscutting concerns are modularized as aspects. Display updating pointcut after (FigureElement fe): (call(void set*(..)) && target(fe) { fe.display.update(fe); } AspectJ advice

  6. Our research • We provide a new weaving mechanism based on component-and-connectorarchitecture. • We propose a new interface mechanism called Weaving-interface. • We provide a new AOP language called ccJava. ccJava: Class-based Crosscutting language for Java

  7. Image of our idea weaving I/F weaving I/F weaving I/F Contribution Proposal of Component-based AOP Architectural AOP Towards MDD Our approach is effective for software modularity, evolution, and reuse. Concern Component (class) Concern Component (class) Concern Component (class) connector connector weaving I/F Concern weaving by connectors Concern Component (class)

  8. Outline • Motivation • Weaving-interface & ccJava • Example programs • Implementation • Conclusion & Current work

  9. 1. Motivation

  10. Interface in OOP • A client of a class has only to be aware of methods exposed by an interface of the class. • A class can be modified without being aware of the client if the class does not change the interface. component (class) programmer interface client of a class interface component (class) programmer

  11. However, in AOP … • It is not necessarily easy for a programmer to understand the overall behavior of a woven program because a weaving modifies the behavior of a method defined in a class.

  12. Our approach – Weaving-interface • A programmer who defines a weaving has only to be aware of weaving-interfaces. • A programmer of the class can change its implementation without being aware of the client if the class conforms to its weaving-interfaces. weaving I/F weaving I/F weaving I/F Concern Component (class) Concern Component (class) Concern Component (class) connector Component connector weaving-interface component (class) programmer Component-based AOP Architectural AOP weaving I/F Connector Concern Component (class) Component programmer who connects components component (class) programmer

  13. Related work • AAIF: Aspect-aware interface [Kiczales 2005] • Open modules [Aldrich 2005] • Crosscutting programming interface (XPI) [Sullivan 2005] An interface is determined only once the complete system is known Point implements FigureElement void setX(int): DisplayUpdating - after returning DisplayUpdating.change(); Aspects can be woven to only exposed program points. Open modules support crosscutting within only one class. Our Approach Software Architecture !! An interface for specifying rules for designing aspects and classes public aspect XPointChange { /* The purpose of … */ pointcut change(): execution(void Point.setX(int)) || … }

  14. 2. Weaving-interface & ccJava

  15. Example --- Figure editor Component interface Shape { public void moveBy(int dx, int dy); } class Point implements Shape { int x, y; public int getX() { return x; } public int getY() { return y; } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } public void moveBy(int dx, int dy) { x += dx; y += dy; } } class Line implements Shape { Point p1, p2; public Point getP1() { return p1; } public Point getP2() { return p2; } public void setP1(Point p1) { this.p1 = p1; } public void setP2(Point p2){ this.p2 = p2; } public void moveBy(int dx, int dy) { p1.x += dx; p1.y += dy; p2.x += dx; p2.y += dy; } } class Display { public static void update() { /* the detail is ommited */ } } Component Three concern components are woven together by component and connector architecture based on weaving-interface. Component

  16. AO weaving based oncomponent-connector architecture Weaving-interface wDisplay wPoint wLine redraw class Display class Point class Line change Component redraw + change Connector class Pointimplements Shape { int x, y; public int getX() { return x; } public int getY() { return y; } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } public void moveBy(int dx, int dy) { x += dx; y += dy; } } class Display { public static void update() { } } wLogging class Logging

  17. ccJava: Class-based Crosscutting language for Java Weaving-interface in ccJava Weaving-interface public w_interface wPoint { pointcut change(): execution(void setX(int)) || execution(void setY(int)) || execution(void moveBy(int, int)); import before(), after() returning, around() : change(); } public w_interface wLine { pointcut change(): execution(void setP1(Point)) || execution(void setP2(Point)) || execution(void moveBy(int, int)); import before(), after() returning, around() : change(); } public w_interface wDisplay { pointcut redraw(): execution(void update()); import before(), after() returning : redraw(); export redraw(); } Port Definition Weaving-interface+Connector is a kind of ADL (Architecture Description Language) Connector descriptions depend on only weaving-interfaces. Architecture can be represented by Weaving-interface + connector. Coordination Type Before After Around introduce Connector weave { class Point implements wPoint; class Line implements wLine; class Display implements wDisplay; connect(port1:wDisplay.redraw, port2:{wPoint || wLine}.change) { after() returning : port2 { port1.proceed(); } } Port Connection Coordination Code

  18. 3. Example programs

  19. Example (1) --- Method composition Weaving-interface Component public w_interfacewColor { pointcut change() : execution(voidsetColor(int)); export change(); } public w_interfacewPoint { pointcut change(): execution(voidsetX(int)) || execution(voidsetY(int)) || execution(voidmoveBy(int, int)); import before(), after() returning, around() : change(); } weave { class Color implements wColor; class Point implements wPoint; connect(port1:wColor.change, port2:wPoint.change){ around() : port2 { port2.proceed(); port1.proceed();}} } Point Color setX setY moveBy setColor behavioral composition Connector

  20. Example (2) --- Class composition (Inter-type declaration) Weaving-interface Component public w_interface wColor { pointcut color_property() : field(int color) || method(void setColor(int))|| method(int getColor()); export color_property(); } public w_interface wColorPoint extends wPoint{ pointcut thisClass() : class(this); import introduce() : thisClass(); } weave { class Color implements wColor; class Point implements wColorPoint; connect(port1:wColor.color_property, port2:wColorPoint.thisClass) { introduce() : port2 from port1; } } Point Color color setX setY moveBy setColor getColor structural composition Connector Point color setX setY moveBy setColor getColor

  21. Example (3) --- Software evolution with ccJava version 1 version 2 Component Component class Point implements Shape { int x, y; public int getX() { return x; } public int getY() { return y; } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } public void moveBy(int dx, int dy) { x += dx; y += dy; } } class Point implements Shape { int x, y; public int getX() { return x; } public int getY() { return y; } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } public void moveByPlus (int dx, int dy) { x += dx; y += dy; } } Connector weave{ class Point implements wPoint replacing moveBy with moveByPlus; class Line implements wLine; class Display implements wDisplay; connect(port1:wDisplay.redraw, port2:{wPoint || wLine}.change){ after() returning : port2 { port1.proceed();}} } Renaming Weaving-interfaces do not have to be modified !

  22. Example (4) --- Interface for dealing with multiple classes Weaving-interface public w_interface wChange { pointcut change(): execution(void set*(..)) || execution(void moveBy(int, int)); import before(), after() returning, around() : change(); } class Pointimplements Shape { int x, y; public int getX() { return x; } public int getY() { return y; } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } public void moveBy(int dx, int dy) { x += dx; y += dy; } } Connector weave { class Point implements wChange; class Line implements wChange; class Display implements wDisplay; connect(port1:wDisplay.redraw, port2:wChange.change){ after() returning : port2 { port1.proceed(); } } } • The scope of the weaving impact is limited to classes that implement wChange. • We have only to look at Point and Line.

  23. Evaluation:Expressiveness for crosscutting descriptions NAW NOC NOC/NAW AspectJ (AAIF) 1 2 2 ccJava as an open module 2 2 1 ccJava using wildcard 1 2 2 DisplayUpdating wPoint wLine Good Weak wChange Good Cannot crosscut multiple classes Can crosscut multiple classes NAW: number of aspects or weaving-interfaces NOC: number of classes (Point, Line)

  24. Evaluation:Traceability of weaving impact Linguistic reasoning is difficult Linguistic reasoning is easy NOC IFW NOIF AspectJ 1 all aspects number of aspects AAIF 1 AAIF 1 ccJava 1 weaving-I/Fs number of weaving-IFs Weak Good Good number of all aspects > number of implemented weaving-IFs NOC: number of classes IFW: impact factors for weaving NOIF: number of impact factors

  25. 4. Implementation

  26. Compiler construction ccJava code (weaving-interface) Java code (class) ccJava parser ccJava compiler AspectJ code generator Aspect-Factory class generator AspectJ code (aspect) AspectJ weaver executable program

  27. Generated code generated aspect aspect wPoint { Display display = new DisplayFactory.getInstance(); pointcut change(): execution(void Point.setX(int)) || execution(void Point.setY(int)) || execution(void Point.moveBy(int, int)); after() returning: change() { display.update(); } } public class DisplayFactory { private static Display instance = new Display(); public static Display getInstance { return instance; } } generated factory class If a programmer wants to define a specific factory class, … weave { class Display implements wDisplay factory UserDefinedFactory; /* other definitions are omitted */ }

  28. Verifiable AO MDD Architectural Design • Not only programming-level but also design-level notion • ADL for bridginga gap between architectural design and implementation Designs and verifies an architecture represented by a set of weaving-interfaces (Alloy-based architecture verification) Weaving-interface Implements verified weaving interfaces Java

  29. ccModeler & ccJava ccModeler Architectural Design Architecture Design & verification Designs and verifies an architecture represented by a set of weaving-interfaces ccJava Weaving-interface Refinement Implements verified weaving interfaces Java

  30. 6. Conclusion & Current ongoing work

  31. Conclusion • A new interface mechanism Weaving-interface • A new weaving mechanism based on component-and-connector architecture Flexible Weaving Mechanism !

  32. Current work-- From Weaving-interface to Archface • Archface: architectural interface for bridging a gap between design modeling and implementation • Archface integrates not only design modeling with its implementation but also AO with OO.

  33. Example: Observer Pattern Archface In archface, a collaborative architecture is specified by a set of ports based on the pointcut mechanism. Implementation Pointcut-based interface

More Related