Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing.

Slides:



Advertisements
Similar presentations
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
Advertisements

©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 32 Slide 1 Aspect-oriented Software Development.
Aspect Oriented Programming - AspectJ Radhika Rajput.
Inheritance Inheritance Reserved word protected Reserved word super
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Overview of AspectJ Aspect Oriented Software Development Seminar Technion presented by Oren Mishali.
Explaining DJ with AOP. DJ ClassGraph.traverse (this,whereToGo,whatToDo) Intertype declaration Advice.
University of British Columbia Software Practices Lab Fluid AOP Join Point Models Terry Hon Gregor Kiczales.
ITEC200 – Week03 Inheritance and Class Hierarchies.
1 Aspect Oriented Programming Programming Languages Seminar Presenter: Barış Aktemur University of Illinois 18 Feb Mostly taken from Bedir Tekinerdogan’s.
Road Map Introduction to object oriented programming. Classes
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
More on AspectJ. aspect MoveTracking { private static boolean _flag = false; public static boolean testAndClear() { boolean result = _flag; _flag = false;
AOP and Aspect C++ presentation by Igor Kotenkov based on presentation by Andreas Gal, Daniel Lohmann and Olaf Spinczyk.
Java Methods By J. W. Rider. Java Methods Modularity Declaring methods –Header, signature, prototype Static Void Local variables –this Return Reentrancy.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Java Classes, Interfaces, and Types 1.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
Master’s Thesis Defense: Aspectual Concepts John J. Sung.
Session 2: AspectJ Mark Stobbe September 13,
Polymorphism, Inheritance Pt. 1 COMP 401, Fall 2014 Lecture 7 9/9/2014.
Integrating Independent Components with On-Demand Remodularization based on OOPSLA 2002 paper by Mira Mezini Klaus Ostermann Prepared by Karl Lieberherr.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 32 Slide 1 Aspect-oriented Software Development 1.
Expression evaluation E : S | C. S = int. C = Op E E. Op : A | M. A = “+”. M = “*”.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
Aspect Oriented Programming Gülşah KARADUMAN.
Slides for Gregor Kiczales Two versions –short version: Crosscutting capabilities for Java and AspectJ through DJ (4 viewgraphs only) –long version: Controlling.
A Meta-Level Specification and Profile for AspectJ in UML Joerg Evermann School of Information Management Victoria University of Wellington.
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.
Master’s Thesis Defense: Aspectual Concepts John J. Sung.
Object-Oriented Design CSC 212. Announcements This course is speeding up and we are starting new material. Please see me if you feel this is going too.
John J. Sung TA Consulting. Motivation for TraversalJ KL Enterprises identified AOP Enter into the AOP market early Add value by adding traversals to.
AOP Foundations Doug Orleans Karl Lieberherr. What we did earlier AOP languages have the following main elements: –a join point model (JPM) wrt base PL.
Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing.
Adaptive Software Kevin Cella Graduate Seminar 02/04/2005.
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.
Demeter Aspects We study techniques for the emerging area of Aspect-Oriented Software Development and focus on the following areas:  Aspectual Collaborations.
Checking LoD in AspectJ Show the idea, not the details. How can we precisely express it in a programming language?
Translating Traversals to AspectJ. Outline Motivation Demeter Process for Traversals AspectJ Translation Process.
Introduction to Object-Oriented Programming Lesson 2.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
DJ: traversal-visitor-style programming in Java Josh Marshall/ Doug Orleans Want to add more on traversal through collections and Aspectual Components.
Aspect Oriented Programming Adlux Consultancy Services Pvt Ltd
问题 Code scattering Blocks of duplicated code Blocks of complementary code, and different modules implementing complementary parts of the concern Code.
Comparison of Different AOP Approaches Presented by: Xiaojing Wang.
AOP/cross-cutting What is an aspect?. An aspect is a modular unit that cross-cuts other modular units. What means cross-cutting? Apply AOP to AOP. Tease.
CSC450 Software Engineering Devon M. Simmonds University of North Carolina, Wilmington 1.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
UBC software modularity group 1/14/02 UCSD1 Discussion with Kiczales at UBC Ontology of AOP Ontology is the study of what there is, an inventory of what.
COM1205 TraversalJ Project* Pengcheng Wu Feb.25,2003.
AOP with AspectJ Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
AO Mechanisms in Demeter1 Discussion with Gregor Kiczales at UBC Ontology of AOP Ontology is the study of what there is, an inventory of what exists. An.
Talk only to your friends that share the same concerns (Law of Demeter for Concerns) Midterm Review February 2004.
Crosscutting Capabilities for Java and AspectJ through DJ
Part II – AspectC++ Language
Chapter 3: Using Methods, Classes, and Objects
Discussion with Gregor Kiczales at UBC
Demeter Aspects Who We Are Aspectual Collaborations
Aspect-Oriented Programming
Aspect-Oriented Design and Patterns
Better Separation of Crosscutting Concerns with Aspectual Components
AOSD and the Law of Demeter: Shyness in Programming
Options for Demeter intergration into AspectJ
Adaptive Programming in JAsCo
Refactoring the Aspectizable Interfaces: An Empirical Assessment
Presentation transcript:

Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing sets of join points (JPS) –a means of specifying behavior involving join points (BJP) –encapsulated units combining JPS and BJP (CSB) –method of attachment of units to base program (AU)

Comparing AspectJ DemeterJ DJ ATC AspectC

AspectJ JPM principled points of execution –message sends (basically a method call), message receptions, method executions –field references (get and set) –exception throwing and handling –constructor execution which context is available at each join point?

AspectJ JPS pointcut designators –primitive: calls(sig), receptions(sig), executions(sig), instanceof(type), within(type), cflow(pcd), getter(sig?), setter(sig?) –operators: &&, ||, ! can name a pointcut and expose context –pointcut foo (V v):pcd (using v); pointcut maybe abstract (declaration) and defined in a subaspect.

AspectJ BJP before, after, around: a pointcut. can refer to thisJoinPoint –explain join point object: instance of JoinPoint class. Interface: getSignature(), getActualParameters(),… JoinPoint has eleven subclasses: CallJoinPoint, ReceptionJoinPoint, ExecutionJoinPoint, ExceptionJoinPoint, … in around (instead of) can say: proceed()

AspectJ CSB an aspect contains a list of advice and point cut declarations and introductions and regular fields and methods.

Explaining aspect instance when you declare an aspect, you say either of eachJVM() or of eachobject(pcd) logging: log stream put in aspect instance of each VM (one instance for whole program) dft: mark field put it in aspect instance of each object (node object of the graph)

AspectJ AU ajc takes a list of files: aspects and classes and weaves them together.

DemeterJ JPM traversal method calls on Java object, constructor calls

DemeterJ JPS strategies –define family of traversal programs to be enhanced –approximation: function mapping object graphs to subgraphs sentences –define family of Java objects: executions of constructor calls

DemeterJ BJP visitor classes –before *

DemeterJ CSB adaptive methods –void f() to S (V1, V2)

DemeterJ AU make new.beh file, add to.prj file, demeterj

DJ JPM object graph : nodes and edges principled points: traversal of nodes or edges fix a traversal algorithm

DJ JPS strategies –define family of traversal programs to be enhanced –approximation: function mapping object graphs to subgraphs (object graph slices)

DJ BJP visitor classes –before(A a), after(C c), cbefore_x(Object a, Object b), caround_x(Object a, Object b, Subtraverser st) –each method applies to a different part of the point cut (strategy)

DJ CSB aspectual methods void f(ClassGraph cg) { cg.traverse(this, “from A to S”, new Visitor() {…});}

DJ AU add methods to classes

DJ: Second view: Doug

DJ JPM object graph slices: nodes and edges fix a traversal algorithm

DJ JPS strategies –define family of traversal programs to be enhanced –approximation: function mapping object graphs to subgraphs (object graph slices) in addition: visitor methods are pointcut designators pointcut designators are encoded in signatures of visitor methods

DJ BJP visitor classes –each visitor method is advice on the point cut specified by the method signature

DJ CSB a visitor class is a package of advice when you use a visitor in a traversal of an ogs (in traverse) then each pointcut is intersected with the traversal pointcut, namely cflow(traverse). (can also use within)

DJ AU to attach an aspect you call traverse with an aspect (visitor). traverse expression attaches the aspect to an object graph slice.

AspectC JPM function calls, variable references data available: args to function calls

AspectC JPS point cut designators –call (foo( c )): all calls of function foo with one argument –cflow( any point cut designator): “whatever comes afterwards on the stack” –varref(name) –combine with &&, || and !

AspectC BJP before, after, around

AspectC CSB are hardwired together: when advice is given, you need to give point cut

AspectC AU concatenated to the source

ATC JPM Aspects in Tiny CLOS generic function receptions, method executions use MOP to implement aspects what data is exported: see join point object

ATC JPS ! point cut designators –predicate on aspect instance and join point object –explain join point object: instance of class. Interface: slots: generic (generic function being called), args (actual parameters), stack (stack of join points in current control flow) has two subclasses: and has additional slot: method (being executed) (all the traversal methods in the cflow of the first traversal call)

ATC BJP before, after, around: take aspect instance and join point object as argument. around has third arg: continuation generic function...

ATC CSB advice has a pointcut generic function (like an abstract pointcut in AspectJ). Methods of generic function are specified separately. an aspect contains a list of advice (no point cut declaration) an aspect is an instance of

Explaining aspect instance class has two subclasses: logging: log stream put in aspect instance of each VM (one instance for whole program) dft: mark field put it in aspect instance of each object (node object of the graph)

ATC AU ! mixin: has slot aspects: holds list of attached aspects is a subclass of both and ( is the class of all generic functions) add-aspect!, remove-aspect! all generic functions in base program are aspectizable (non-obliviousness ok)

Aspectual Collaborations JPM principled points of execution –abstract join points that are mapped by the adapter to concrete ones –execution of methods modified by collaboration enhance the class graph: open classes: add more members to existing classes which context is available at each join point?

Aspectual Collaborations JPS sets of join points: collaboration + adapter (in the adapters we express the cross cutting) collaboration roles only: have the flavor of an abstract pointcut.

Aspectual Collaborations BJP before, after, around: for methods can refer to actual parameters in replace (around (instead of)) can say: expected()

Aspectual Collaborations CSB collaborations and adapters

Aspectual Collaborations AU ac-compiler (non existent) takes a list of files: classes and collaborations and adapters and weaves them together.

Using AspectJ to implement collaborations/adapters AspectJ can only express the adapted collaborations AspectJ supports interfaces with full methods and multiple inheritance

Goal Input: classes, collaborations, adapters Output: AspectJ code