Aspect-Oriented Software Development (AOSD) Tutorial #2 AspectJ Basics.

Slides:



Advertisements
Similar presentations
A Brief Introduction to Aspect-Oriented Programming Zhenxiao Yang.
Advertisements

1 An Aspect-Aware Outline Viewer Michihiro Horie and Shigeru Chiba Tokyo Institute of Technology, Japan.
Lecture 27 Exceptions COMP1681 / SE15 Introduction to Programming.
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.
Advice Weaving in AspectJ Alex Gontmakher. Outline Possible implementation approaches Quick JVM primer AJC implementation Performance Evaluation.
359C 10/1/05 Eric Wohlstadter Introductions –Name –Degree objective/Year –Research Area (or interests) Syllabus Aspect-Oriented Programming –AspectJ –AspectC.
1 Aspect Oriented Programming Programming Languages Seminar Presenter: Barış Aktemur University of Illinois 18 Feb Mostly taken from Bedir Tekinerdogan’s.
Lecture 28 More on Exceptions COMP1681 / SE15 Introduction to Programming.
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.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University Regression Test Selection for AspectJ Software Guoqing Xu and Atanas.
Software modularity group Gregor Kiczales Professor and NSERC/Xerox/Sierra Systems Software Design Chair University of British Columbia Principal Scientist.
Aspect-Oriented Software Development (AOSD) Additional Tutorial.
Aspect-Oriented Software Development (AOSD) Tutorial #3 AspectJ - continued.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University A Framework for Source-Code- Level Interprocedural Dataflow Analysis.
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.
Aspect-Oriented Software Development (AOSD) Tutorial #3 AspectJ - continued.
Introduction to Aspect- Oriented Programming CS 3360 Gregor Kiczales, et. al. Getting started with AspectJ, CACM, 44(10):59-65, October Fall 2012.
Outline Introduction Problem Statement Object-Oriented Design Aspect-Oriented Design Conclusion Demo.
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.
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,
1 An Aspect-oriented Weaving Mechanism Based on Component-and-Connector Architecture Naoyasu Ubayashi (Kyushu Institute of Technology) February 12, 2008.
1 A Parameterized Interpreter for Modeling Different AOP Mechanisms Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Genki Moriyama(Kyushu Institute.
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,
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.
Virtual Support for Dynamic Join Points C. Bockisch, M. Haupt, M. Mezini, K. Ostermann Presented by Itai Sharon
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.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
CS 11 java track: lecture 2 This week: more on object-oriented programming (OOP) objects vs. primitive types creating new objects with new calling methods.
1 Contract-based Verification for Aspect-oriented Refactoring Naoyasu Ubayashi(Kyushu Institute of Technology) Jinji Piao(Kyushu Institute of Technology)
Aspect Oriented Development Alex Beatty.  Purpose  Cross-cutting Concerns  Join Points, Pointcuts, and Advices  Weaving  Invasive vs. Non-Invasive.
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.
FOR LOOP WALK THROUGH public class NestedFor { public static void main(String [] args) { for (int i = 1; i
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.
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.
A first language for Aspect-Oriented Programming
AOP with AspectJ Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
AP Computer Science A – Healdsburg High School 1 Unit 9 - Parameter Passing in Java.
Exception and Exception Handling. Exception An abnormal event that is likely to happen during program is execution Computer could run out of memory Calling.
Loops, Methods, Classes Using Loops, Defining and Using Methods, Using API Classes, Exceptions, Defining Classes Svetlin Nakov Technical Trainer
Copyright 2010 by Pearson Education Building Java Programs Chapter 8 Lecture 8-3: Constructors; Encapsulation reading: self-checks: #13-18,
Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing.
An Interface Mechanism for Encapsulating Weaving in Class-based AOP
Aspect-Oriented Generation of the API Documentation for AspectJ
Computing Adjusted Quiz Total Score
Aspect-Oriented Programming
A Brief Introduction to Aspect-Oriented Programming
Topic 29 classes and objects, part 3
class PrintOnetoTen { public static void main(String args[]) {
Building Java Programs
CSE 142 Lecture Notes Defining New Types of Objects, cont'd.
ITE “A” GROUP 2 ENCAPSULATION.
Presentation transcript:

Aspect-Oriented Software Development (AOSD) Tutorial #2 AspectJ Basics

Aspect-Oriented Software Development (236608) 2 Today: Getting started with AspectJ Advice types Pointcuts –Primitive pointcuts –Pointcuts composition Examples English – AspectJ phrase book (selected entries)

Aspect-Oriented Software Development (236608) 3 Example Class: Point 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) 4 English – AspectJ Phrase Book (1) Pointcut: all the calls to the “getters” of Point A short way to say the same: Is this the same?

Aspect-Oriented Software Development (236608) 5 English – AspectJ Phrase Book (2) What does this mean? pointcut questionPointcut(Point p1, Point p2): (target(p1) && call(void getX(int))) || (target(p2) && call(void getY(int)));

Aspect-Oriented Software Development (236608) 6 Task 1: Positive Quarter Check Task1: After each change in our points, check whether they are in the positive quarter of the space “Positive quarter” means … ? When is the aspect called? (pointcut) - What should the aspect do? (advice) -

Aspect-Oriented Software Development (236608) 7 Task 1 – contd.: Pointcut = ? In words: Where in the code? In AspectJ:

Aspect-Oriented Software Development (236608) 8 Task 1 – contd.: Pointcut = ? Parameters? Pointcut as a whole, in AspectJ:

Aspect-Oriented Software Development (236608) 9 Task1(contd.) Alternative pointcuts?

Aspect-Oriented Software Development (236608) 10 Task 1 – contd.: Advice = ? Advice type: Advice parameters:

Aspect-Oriented Software Development (236608) 11 Task 1: Advice = ? (In AspectJ)

Aspect-Oriented Software Development (236608) 12 Task 2: Positive Quarter Alert Task2: Alert the user before each change that will result in points out of the positive quarter of the space Pointcut = ?

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

Aspect-Oriented Software Development (236608) 14 Task 3: Enforce Positive Quarter Task3: Make sure that all our points are in the positive quarter of the space Pointcut = ?

Aspect-Oriented Software Development (236608) 15 Task 3 – contd. Advice = ?

Aspect-Oriented Software Development (236608) 16 Call vs. Execute – contd. call(void m()) && withincode(void m()) = ? execution(void m()) && withincode(void m()) = ? Enclosing code at a call join-point = ? Enclosing code at an execution join point = ?

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

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

Aspect-Oriented Software Development (236608) 19 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.goo())); (2) pointcut except2(): cflowbelow(call(void Test.foo()));

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

Aspect-Oriented Software Development (236608) 21 Task 4: Proposed solution-2

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

Aspect-Oriented Software Development (236608) 23 More details… For more details please see the AspectJ Programming Guide, at: progguide/index.html To be continued at the next tutorial…