Aspect-Oriented Software Development (AOSD) Tutorial #3 AspectJ - continued.

Slides:



Advertisements
Similar presentations
AspectWerkz 2 - and the road to AspectJ 5 Jonas Bonér Senior Software Engineer BEA Systems.
Advertisements

1 An Aspect-Aware Outline Viewer Michihiro Horie and Shigeru Chiba Tokyo Institute of Technology, Japan.
Overview of AspectJ Aspect Oriented Software Development Seminar Technion presented by Oren Mishali.
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 Software Development (AOSD) Tutorial #2 AspectJ Basics.
Aspect-Oriented Software Development (AOSD) Tutorial #5 Categories of Aspects – contd.; LTL properties formalization; Assume – guarantee specifications.
Aspect-Oriented Software Development (AOSD) Tutorial #4 Categories of Aspects.
Aspect-Oriented Software Development (AOSD) Tutorial #7 Assume – guarantee specifications; EAOP.
Aspect-Oriented Software Development (AOSD) Tutorial #5 Categories of Aspects – contd.; LTL properties formalization.
Aspect-Oriented Software Development (AOSD) Tutorial #4 Categories of Aspects.
Aspect-Oriented Software Development (AOSD) Tutorial #8 Composition Filters.
Aspect-Oriented Software Development (AOSD) Tutorial #2 AspectJ Basics.
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 8: Classes and Objects.
Inheritance and Polymorphism Recitation – 10/(16,17)/2008 CS 180 Department of Computer Science, Purdue University.
Aspect-Oriented Software Development (AOSD) Additional Tutorial.
Aspect-Oriented Software Development (AOSD) Tutorial #6 Categories of Aspects – contd.; LTL properties formalization; Assume – guarantee specifications.
Aspect-Oriented Software Development (AOSD) Tutorial #3 AspectJ - continued.
Session 15 Modeling Traceability of Concerns in Architectural Views Mark Stobbe October 29,
Aspect-Oriented Software Development (AOSD) Tutorial #5 Categories of Aspects – contd.; LTL properties formalization.
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 #7 Assume – guarantee specifications; EAOP.
XFindBugs: eXtended FindBugs for AspectJ Haihao Shen, Sai Zhang, Jianjun Zhao, Jianhong Fang, Shiyuan Yao Software Theory and Practice Group (STAP) Shanghai.
Intro to Java Programming  A computer follows the instruction precisely and exactly.  Anything has to be declared and defined before it can be used.
CMSC 202 Interfaces. 11/20102 Classes and Methods When a class defines its methods as public, it describes how the class user interacts with the method.
Outline Introduction Problem Statement Object-Oriented Design Aspect-Oriented Design Conclusion Demo.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
Session 2: AspectJ Mark Stobbe September 13,
Using Aspects to Support the Software Process: XP over Eclipse Oren Mishali and Shmuel Katz Technion, Israel Institute of Technology.
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,
Inheritance - Polymorphism ITI 1121 Nour El Kadri.
AOSD1 Aspect-Oriented Software Design Karl Lieberherr Theo Skotiniotis.
Working with arrays (we will use an array of double as example)
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
Aspect-Oriented Programming and Modular Reasoning G. KiczalesM. Mezini Presented by Alex Berendeyev.
CSC1401 Classes - 2. Learning Goals Computing concepts Adding a method To show the pictures in the slide show Creating accessors and modifiers That protect.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
1 CSC/ECE 517 Fall 2010 Lec. 3 Overview of Eclipse Lectures Lecture 2 “Lecture 0” Lecture 3 1.Overview 2.Installing and Running 3.Building and Running.
Inter-Type Declarations in AspectJ Awais Rashid Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
AspectJ – AOP for Java Tom Janofsky. Instructor at Penn State Abington Consultant with Chariot Solutions JUG Member.
Course Progress Lecture 1 –Java data binding: Basket example: UML class diagram -> class dictionary without tokens-> language design -> class dictionary.
1 Contract-based Verification for Aspect-oriented Refactoring Naoyasu Ubayashi(Kyushu Institute of Technology) Jinji Piao(Kyushu Institute of Technology)
Alloy-based Lightweight Verification for Aspect-oriented Architecture Naoyasu Ubayashi(Kyushu Institute of Technology) Yuki Sato(Kyushu Institute of Technology)
CreatingClasses-SlideShow-part31 Creating Classes part 3 Barb Ericson Georgia Institute of Technology Dec 2009.
CS305j Introduction to Computing Classes II 1 Topic 24 Classes Part II "Object-oriented programming as it emerged in Simula 67 allows software structure.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
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.
AOSD'04, Lancaster, UK 1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech) Shigeru Chiba (Tokyo Tech) Michiaki Tatsubori.
CSC450 Software Engineering Devon M. Simmonds University of North Carolina, Wilmington 1.
A first language for Aspect-Oriented Programming
AOP with AspectJ Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
COMP Inheritance and Polymorphism Yi Hong June 09, 2015.
Copyright 2010 by Pearson Education Building Java Programs Chapter 8 Lecture 8-3: Constructors; Encapsulation reading: self-checks: #13-18,
Classes and Objects Introduced
An Interface Mechanism for Encapsulating Weaving in Class-based AOP
Programming in C# Properties
CSC 113 Tutorial QUIZ I.
CMSC 202 Interfaces.
Object initialization: constructors
Topic 29 classes and objects, part 3
class PrintOnetoTen { public static void main(String args[]) {
Building Java Programs
Generics, Lambdas, Reflections
An Extensible Contract Verifier for AspectJ
Barb Ericson Georgia Institute of Technology Oct 2005
Aspect Oriented Programming
CMSC 202 Interfaces.
Topic 29 classes and objects, part 3
Topic 29 classes and objects, part 3
Presentation transcript:

Aspect-Oriented Software Development (AOSD) Tutorial #3 AspectJ - continued

Aspect-Oriented Software Development (236608) 2 Today: AspectJ - Continued Additional pointcut types –cflow –cflowbelow Intertype declarations Compilation errors declarations Examples English – AspectJ phrase book (selected entries)

Aspect-Oriented Software Development (236608) 3 Task 1: Greeting before printing Public class Test { public static void main(String[] args) { f(); } static void f() { g(); } static void g() { System.out.println( “ message from g ” ); } Task: Before each printing operation, print a greeting message

Aspect-Oriented Software Development (236608) 4 English – AspectJ Phrase Book (3) “All the exceptions thrown by f()” “All the exceptions thrown while f() is executed:”

Aspect-Oriented Software Development (236608) 5 English – AspectJ Phrase Book (4) “All the exceptions thrown by functions of class Test” What is the relationship between: (1) pointcut except1(): cflow(call(void Test.g())); (2) pointcut except2(): cflowbelow(call(void Test.f()));

Aspect-Oriented Software Development (236608) 6 Task 1: Proposed solution-1

Aspect-Oriented Software Development (236608) 7 Task 1: Proposed solution-2

Aspect-Oriented Software Development (236608) 8 Cflow Pointcuts Combination P Q cflow(P) cflow(Q)cflow(P) && cflow(Q) P && Q cflow(P && Q)

Aspect-Oriented Software Development (236608) 9 Example Class: Point - reminder class Point { private int x, y; public Point(int x, int y) { this.x = x; this.y = y; } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } public void MoveTo(Point p) {setX(p.x); setY(p.y); } public int getX() { return x; } public int getY() { return y; } }

Aspect-Oriented Software Development (236608) 10 Task 2: Named Points Task2: Every point should have a name, and each time the point is moved, the user should get a message with the name of the point and its new coordinates. Pontcut = ?

Aspect-Oriented Software Development (236608) 11 Task 2 – contd. Advice = ? Add the “name” field to Point

Aspect-Oriented Software Development (236608) 12 Task 2 – version2. Another way to add the “name” field to Point Assume there is a class NamedObject in a base system: public class NamedObject { private String name; … public NamedObject() {this.name = "";} … public void setName(String newName) {this.name = newName;} public String getName() {return this.name;} }

Aspect-Oriented Software Development (236608) 13 Task 2 – contd. Advice = ? – contd. Advice type = ? The advice:

Aspect-Oriented Software Development (236608) 14 Task 2 – contd. Is that enough to add the name?

Aspect-Oriented Software Development (236608) 15 Task 2-A Pointcut = ? (reminder) Advice = ?

Aspect-Oriented Software Development (236608) 16 Task 2-A – contd. Name generation: Advice as a whole:

Aspect-Oriented Software Development (236608) 17 Task 3: Contract Enforcement Example Constraint : only the factory methods can add an element to the registry of figure elements. Meaning: ensures that no figure element is added to the registry more than once. Implementation:

Aspect-Oriented Software Development (236608) 18 More to Inter-type Declarations declare error: Pointcut: String; declare warning: Pointcut: String; New powerful types of compilation warnings and errors! Syntax: For the contract enforcement example: For example, to identify method calls that should not exist in a correct program Attention! Only static information will be used at the join-points!

Aspect-Oriented Software Development (236608) 19 More to AspectJ: Subtypes at pointcuts Example base classes: public class NamedObject { …} public class NamedFigure extends NamedObject { …} Example aspect: public aspect NamedObjectsObserver { …}

Aspect-Oriented Software Development (236608) 20 Subtypes at pointcuts – contd. class public aspect NamedObjectsObserver { pointcut publicCalled1(): call(public * NamedObject.*(..)); pointcut publicCalled2(): call(public * NamedObject+.*(..)); pointcut publicCalled3(): call(public * (NamedObject+ && !NamedObject).*(..)); after() : publicCalled1() { System.out.println("Public (1)"+thisJoinPoint); } after() : publicCalled2() { System.out.println("Public (2)"+thisJoinPoint); } after() : publicCalled3() { System.out.println("Public (3)"+thisJoinPoint); } }