Explaining DJ with AOP. DJ ClassGraph.traverse (this,whereToGo,whatToDo) Intertype declaration Advice.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

The Singleton Pattern II Recursive Linked Structures.
METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
1 Shyness in Programming Karl Lieberherr Demeter Research Group Northeastern University Boston.
Overview of AspectJ Aspect Oriented Software Development Seminar Technion presented by Oren Mishali.
University of British Columbia Software Practices Lab Fluid AOP Join Point Models Terry Hon Gregor Kiczales.
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales.
More on AspectJ. aspect MoveTracking { private static boolean _flag = false; public static boolean testAndClear() { boolean result = _flag; _flag = false;
Aspect-Oriented Software Development (AOSD) Tutorial #3 AspectJ - continued.
Integration of Demeter and AspectJ (DAJ) John J. Sung.
Aspect-Oriented Software Development (AOSD) Tutorial #3 AspectJ - continued.
Java CourseWinter 2009/10. Introduction Object oriented, imperative programming language. Developed: Inspired by C++ programming language.
XFindBugs: eXtended FindBugs for AspectJ Haihao Shen, Sai Zhang, Jianjun Zhao, Jianhong Fang, Shiyuan Yao Software Theory and Practice Group (STAP) Shanghai.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Debugging Support.
Master’s Thesis Defense: Aspectual Concepts John J. Sung.
Change Impact Analysis for AspectJ Programs Sai Zhang, Zhongxian Gu, Yu Lin and Jianjun Zhao Shanghai Jiao Tong University.
Slides for Gregor Kiczales Two versions –short version: Crosscutting capabilities for Java and AspectJ through DJ (4 viewgraphs only) –long version: Controlling.
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.
Compiler Construction Dr. Noam Rinetzky and Orr Tamir School of Computer Science Tel Aviv University
CCC: An Aspect-Oriented Intermediate Language on.Net Platform Yingfei Xiong and Feng Wan University of Electronic Science and Technology of China, China.
AspectWrapper CHALFOUN Pierre et BUIST Éric. Overview Introduction – what and why In a nutshell – main components Our approach – how we did it Demo –
Master’s Thesis Defense: Aspectual Concepts John J. Sung.
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.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
Region Pointcut for AspectJ Shumpei Akai Shigeru Chiba Muga Nishizawa.
1 Functional Visitor Ø Motivation Example Container checking -- Make sure each Container is not overloaded Weight Item + int total( ) w Container + int.
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.
问题 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.
Creating Web Services Presented by Ashraf Memon Presented by Ashraf Memon.
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.
UCI Feb 031 Adaptive Aspect-Oriented Programming in AspectJ Karl J. Lieberherr Northeastern University Joint work of Demeter Research Group.
Java: Variables and Methods By Joshua Li Created for the allAboutJavaClasses wikispace.
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.
Enum,Structure and Nullable Types Ashima Wadhwa. Enumerations, Enumerations, or enums, are used to group named constants similar to how they are used.
COM1205 TraversalJ Project* Pengcheng Wu Feb.25,2003.
AOP with AspectJ Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
1 An AOP Implementation Framework for Extending Join Point Models Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Hidehiko Masuhara(University.
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.
COP 3330 Notes 3/7. Today’s Topics Exceptions Abstract Classes.
1 Aspectual Caml an Aspect-Oriented Functional Language Hideaki Tatsuzawa Hidehiko Masuhara Akinori Yonezawa University of Tokyo.
Jesse proposal1 Jesse’s proposal Karl Lieberherr.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing.
Modern Programming Tools And Techniques-I
using System; namespace Demo01 { class Program
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
Discussion with Gregor Kiczales at UBC
For John.
Computing Adjusted Quiz Total Score
Aspect-Oriented Programming
ADAPTIVE PROGRAMMING Sezen ERDEM December 2005.
Java Lesson 36 Mr. Kalmes.
Better Separation of Crosscutting Concerns with Aspectual Components
class PrintOnetoTen { public static void main(String args[]) {
AOSD and the Law of Demeter: Shyness in Programming
Options for Demeter intergration into AspectJ
Chapter 11 Inheritance and Polymorphism Part 1
Aspect Oriented Programming
Presentation transcript:

Explaining DJ with AOP

DJ ClassGraph.traverse (this,whereToGo,whatToDo) Intertype declaration Advice

range of AOP languages means of … join points JPMjoin pointsidentifyingspecifying semantics at AspectJ dynamic JPM points in execution call, get, set… signatures w/ wildcards & other properties of JPs advice static JPMclass memberssignaturesadd members DemeterJ, Demeter/C++ dynamic JPM static JPM 1 static JPM 2 static JPM 3 when traversal reaches object or edge class members visitor method signatures traversal spec. s class graph g class names class graph visitor method bodies s + g (result = traversal implementation) add members class graph with tokens=grammar (result = parsing and printing implementation)

range of AOP languages means of … join points add memberssignaturesclass members static JPM DJ dynamic JPM 1 dynamic JPM 2 dynamic JPM 3 AspectJ dynamic JPM JPM when traversal reaches object or edge (method traverse) when traversal reaches object (methods fetch, gather, asList) nodes in object graphs points in execution call, get, set… join points visitor method signatures source and targets of traversal trav. spec. s class graph g object graph o signatures w/ wildcards & other properties of JPs identifying visitor method bodies method name (fetch, gather, asList) s+g+o(result = traversal implementation = edges to traverse at nodes in object graph) advice specifying semantics at

A Simple Basket Example Basket FruitPencil p f, f2 Orange Weight Color wc String s int i

BasketVisitor class BasketVisitor { int total; public void start() { total = 0; } public int returnValue() { return total; } void before(Weight w) { total += w.get_i(); }

Basket Traversal aspect BasketTraversal { ClassGraph default; ClassGraph myClassGraph = new ClassGraph(default, "from Basket to *"); Visitor BasketVisitor; declare traversal t1(myClassGraph,BasketVisitor) : "from Basket to Weight"; declare traversal t2(myClassGraph,BasketVisitor) : "from Basket via Orange to Weight"; }

Basket Main class BasketMain { static public void main(String args[]) throws Exception { Basket b = new Basket(new Orange(new Color("orange"), new Weight(5)), new Fruit( new Weight(10)), new Pencil() ); BasketVisitor bv = new BasketVisitor(); b.t1(bv); int totalWeight = bv.returnValue(); System.out.println("Total weight of basket = " + totalWeight); b.t2(bv); totalWeight = bv.returnValue(); System.out.println("Total weight2 of basket = " + totalWeight); }

Generated Code for Visitor static BasketVisitor t1_visitor; public void Basket.t1(BasketVisitor v) { t1_visitor=v; t1_visitor.start(); t1(); } before(Weight host) : call(public void t1*()) && target(host) { t1_visitor.before(host); } void Basket.t1() { t1_copy0(); }

Basket Class Graph Basket FruitPencil p f, f2 Orange Weight Color wc String s int i

Generated Code for Traversal // traversal t1 : {source: Basket -> target: Weight} with { } public void Basket.t1_copy0(){ if (f != null) t1_copy0_crossing_f(); if (f2 != null) t1_copy0_crossing_f2(); } public void Basket.t1_copy0_crossing_f() { f.t1_copy0();} public void Basket.t1_copy0_crossing_f2() { f2.t1_copy0();} public void Fruit.t1_copy0(){ if (w != null) t1_copy0_crossing_w(); } public void Fruit.t1_copy0_crossing_w() { w.t1_copy0();} public void Weight.t1_copy0(){ } public void Orange.t1_copy0(){ super.t1_copy0(); } pointcut pointcut_t1() : call(public void t1*()); before () : pointcut_t1 () { System.out.println(thisJoinPoint); }

Explanation for Caching Hw 3 How we would like to write the code in DJ. Only in a test version of DJ. NOT currently available.

class ContainerChecker extends Visitor { Object combine(Object[] values) { int total=0; for(int i=0; i<values.length; i++) { if(values[i]!=null) total+= ((Integer)values[i]).intValue(); } return new Integer(total); } Object around(Weight w,Subtraversal st) { return w.get_value(); }

Object around(Container c,Subtraversal st) { Integer total = (Integer)st.apply("contents"); if (total.intValue() > c.get_capacity(). get_value().intValue()) System.out.println("An Overloaded Container"); return total; }