An Interface Mechanism for Encapsulating Weaving in Class-based AOP

Slides:



Advertisements
Similar presentations
Mohamed ElBendary and John Boyland University of Wisconsin-Milwaukee.
Advertisements

Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
An Aspect-Oriented Approach For Web Application Access Control Presented by: Mohamed Hassan Carleton University Carleton University
1 An Aspect-Aware Outline Viewer Michihiro Horie and Shigeru Chiba Tokyo Institute of Technology, Japan.
Secure Systems Research Group - FAU Aspect Oriented Programming Carlos Oviedo Secure Systems Research Group.
University of British Columbia Software Practices Lab Fluid AOP Join Point Models Terry Hon Gregor Kiczales.
Java.sun.com/javaone/sf | 2004 JavaOne SM Conference | Session BUS JavaOne 2004 What is AOP? Gregor Kiczales AspectMentor.com and University of.
Aspect-Oriented Programming Gregor Kiczales University of British Columbia © Copyright 2004, Gregor Kiczales. All rights reserved.
359C 10/1/05 Eric Wohlstadter Introductions –Name –Degree objective/Year –Research Area (or interests) Syllabus Aspect-Oriented Programming –AspectJ –AspectC.
University of British Columbia Software Practices Lab 2005 CASCON A Fluid AOP Editor Terry Hon Gregor Kiczales.
1 Aspect Oriented Programming Programming Languages Seminar Presenter: Barış Aktemur University of Illinois 18 Feb Mostly taken from Bedir Tekinerdogan’s.
ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales.
Aspect-oriented programming Laura Ricci A.A
Aspect-Oriented Software Development (AOSD) Tutorial #2 AspectJ Basics.
Software modularity group Gregor Kiczales Professor and NSERC/Xerox/Sierra Systems Software Design Chair University of British Columbia Principal Scientist.
More on AspectJ. aspect MoveTracking { private static boolean _flag = false; public static boolean testAndClear() { boolean result = _flag; _flag = false;
Session 15 Modeling Traceability of Concerns in Architectural Views Mark Stobbe October 29,
Aspect-Oriented Programming with AspectJ™ AspectJ.org Xerox PARC Erik Hilsdale Gregor Kiczales with Bill Griswold, Jim Hugunin, Wes Isberg, Mik Kersten.
Aspect-Oriented Software Development (AOSD) Tutorial #3 AspectJ - continued.
A Formal Model of Modularity in Aspect-Oriented Programming Jonathan Aldrich : Objects and Aspects Carnegie Mellon University.
An Introduction to AOP Original slides developed by Julie Waterhouse and Mik Kersten for OOPSLA 2004 AspectJ Tutorial ( kerstens.org/mik/publications/aspectj-
Outline Introduction Problem Statement Object-Oriented Design Aspect-Oriented Design Conclusion Demo.
1 Archface: Architectural Interface -- Bridging a Gap between Design Modeling and Implementation Naoyasu Ubayashi, Hidenori Akatoki, Jun Nomura Kyushu.
Object Oriented Programming Concepts OOP – reasoning about a program as a set of objects rather than as a set of actions Object – a programming entity.
Aspect Oriented Programming Razieh Asadi University of Science & Technology Mazandran Babol Aspect Component Based Software Engineering (ACBSE)
1 Metamodel Access Protocols for Extensible Aspect-Oriented Modeling Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Shinji Sano(Kyushu Institute.
Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) 1 A Small Extension to Java for Class Refinement ACM SAC'08, March 18, 2008.
1 An Aspect-oriented Weaving Mechanism Based on Component-and-Connector Architecture Naoyasu Ubayashi (Kyushu Institute of Technology) February 12, 2008.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 32 Slide 1 Aspect-oriented Software Development 1.
1 Model Compiler Construction Based on Aspect-oriented Mechanisms Naoyasu Ubayashi (Kyushu Institute of Technology) Tetsuo Tamai (University of Tokyo)
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
1 A Parameterized Interpreter for Modeling Different AOP Mechanisms Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Genki Moriyama(Kyushu Institute.
POSL (Principles of Software Languages) Gr. Kyushu Institute of Technology, Japan Pointcut-based Architectural Interface.
Aspect Oriented Programming Gülşah KARADUMAN.
Copyright 2008 by Pearson Education Building Java Programs Chapter 8 Lecture 8-3: Encapsulation, this reading: self-checks: #13-17 exercises:
Kiczales and Mezini - FOAL AOP and Modular Reasoning [ICSE05] Start with first-principles definition of modularity and modular reasoning –localization,
Copyright 2010 by Pearson Education Building Java Programs Chapter 8 Lecture 8-2: Object Behavior (Methods) and Constructors, Encapsulation, this reading:
1 Model Evolution with Aspect-oriented Mechanisms Naoyasu Ubayashi (Kyushu Institute of Technology) Tetsuo Tamai (University of Tokyo) Shinji Sano, Yusaku.
A Distributed Aspect-Oriented System for J2EE Applications Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) Background - As benefits.
AOSD1 Aspect-Oriented Software Design Karl Lieberherr Theo Skotiniotis.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
Devon M. Simmonds Computer Science Department, CSC592 1 Devon M. Simmonds Computer Science Department University of North Carolina, Wilmington
Aspect-Oriented Programming and Modular Reasoning G. KiczalesM. Mezini Presented by Alex Berendeyev.
Architectural Point Mapping for Design Traceability Naoyasu Ubayashi and Yasutaka Kamei Kyushu University, Japan March 26, 2012 FOAL 2012 (AOSD Workshop)
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
1 Contract-based Verification for Aspect-oriented Refactoring Naoyasu Ubayashi(Kyushu Institute of Technology) Jinji Piao(Kyushu Institute of Technology)
Shanghai Jiao Tong University 上海交通大学软件工程中心 Object Oriented Analysis and Design Aspect-Oriented Software Development (AOSD)
Alloy-based Lightweight Verification for Aspect-oriented Architecture Naoyasu Ubayashi(Kyushu Institute of Technology) Yuki Sato(Kyushu Institute of Technology)
AOP and observer pattern. Design pattern General reusable solution to a commonly occurring problem in software design Not a finished design that can be.
Interfaces An interface is like an extreme case of an abstract class – However, an interface is not a class – It is a type that can be satisfied by any.
aspectj tools new and noteworthy Mik Kersten University of British Columbia Adrian Colyer IBM Hursley OOPSLA, October
AOSD'04, Lancaster, UK 1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech) Shigeru Chiba (Tokyo Tech) Michiaki Tatsubori.
R R R A Brief Introduction to Aspect-Oriented Programming.
Introduction to Aspect- Oriented Programming CS 3360 Gregor Kiczales, et. al. Getting started with AspectJ, CACM, 44(10):59-65, October Spring 2012.
CSC450 Software Engineering Devon M. Simmonds University of North Carolina, Wilmington 1.
AspectScope: An Outline Viewer for AspectJ Programs Michihiro Horie, Shigeru Chiba Tokyo Institute of Technology, Japan.
1 An AOP Implementation Framework for Extending Join Point Models Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Hidehiko Masuhara(University.
AspectJ Development Tools Mik Kersten University of British Columbia October 28, 2003.
Copyright 2010 by Pearson Education Building Java Programs Chapter 8 Lecture 8-3: Constructors; Encapsulation reading: self-checks: #13-18,
RoleEP: Role Based Evolutionary Programming for Cooperative Mobile Agent Applications Naoyasu UBAYASHI ( Toshiba Corporation) Tetsuo TAMAI ( University.
Inheritance ITI1121 Nour El Kadri.
MACS 2005 First International Workshop on the Modeling and Analysis of Concerns in Software Concern Management for Constructing Model Compilers -- Towards.
Aspect-Oriented Generation of the API Documentation for AspectJ
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
Aspect-oriented programming
An Extensible Contract Verifier for AspectJ
Aspects at the Design Level
AspectAda Aspect-Oriented Programming for Ada95
Presentation transcript:

An Interface Mechanism for Encapsulating Weaving in Class-based AOP SPLAT2007 An Interface Mechanism for Encapsulating Weaving in Class-based AOP Naoyasu Ubayashi (Kyushu Institute of Technology) Akihiro Sakai (Kyushu Institute of Technology) Tetsuo Tamai (University of Tokyo) March 12, 2007

Today’s my talk The notion of interface is important in module compositions. It is also important in AO weaving. We provide a new interface mechanism Weaving-interface. This introduces a new weaving mechanism based on component-and-connector architecture.

Image of our idea Concern weaving by connectors connector connector weaving I/F weaving I/F weaving I/F Concern Component (class) Concern Component (class) Concern Component (class) connector connector weaving I/F Concern weaving by connectors Concern Component (class)

Outline Motivation Weaving-interface & ccJava Example programs Implementation Related work Conclusion

1. Motivation

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. interface component (class) programmer client of a class interface component (class) programmer

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.

Our approach 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. Component weaving-interface component (class) programmer Connector Component programmer who connects components component (class) programmer

2. Weaving-interface & ccJava

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; } p1.x += dx; p1.y += dy; p2.x += dx; p2.y += dy; class Display { public static void update() { /* the detail is ommited */ } } Component compose three concern components - Point - Line - Display Component

AO weaving based on component-connector architecture export program points (update) wDisplay wPoint wLine class Display class Point class Line Component redraw import program points (at set*, moveBy) logging wLogging Connector class Logging Weaving-interface

ccJava --- a language for supporting weaving-interfaces ccJava: Class-based Crosscutting language for Java ccJava --- a language for supporting weaving-interfaces 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 { execution(void setP1(Point)) || execution(void setP2(Point)) || public w_interface wDisplay { pointcut redraw(): execution(void update()); import before(), after() returning : redraw(); export redraw(); A class must implement methods or fields related exposed by pointcuts. Only the program points selected by pointcuts are target of weaving. 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(); } }

3. Example programs

Example (1) --- Method composition Weaving-interface Component public w_interface wColor { pointcut change() : execution(void setColor(int)); export change(); } 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(); weave { class Color implements wColor; class Point implements wPoint; connect(port1:wColor.change, port2:wPoint.change){ around() : port2 { port2.proceed(); port1.proceed();}} Color Point setX setY moveBy setColor behavioral composition Connector

Example (2) --- 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; } Color Point color setX setY moveBy setColor getColor structural composition Connector Point color setX setY moveBy setColor getColor

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();}} } Weaving-interfaces do not have to be modified !

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(); } 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.

4. Implementation

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

Generated code generated aspect generated factory class 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 */ }

5. Related work

Related work Aspect-aware interface [Kiczales, et al. 2005] Open modules [Aldrich2005] Crosscutting programming interface (XPI) [Sullivan, et al. 2005]

Expressiveness for crosscutting descriptions NAW NOC NOC/NAW AspectJ 1 2 2 ccJava as an open module 2 2 1 ccJava using wildcard 1 2 2 NWA: number of aspects or weaving-interfaces NOC: number of classes

Traceability of weaving impact NOC IFW NOIF AspectJ 1 all aspects number of aspects AAIF(*) 1 AAIF 1 ccJava 1 weaving-I/Fs number of weaving-IFs * AAIF: Aspect-aware Interface number of all aspects > number of implemented weaving-IFs NOC: number of classes IFW: impact factors for weaving NOIF: number of impact factors

6. Conclusion

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