Adaptive Programming in JAsCo

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

ASTA Aspect Software Testing Assistant Juha Gustafsson, Juha Taina, Jukka Viljamaa University of Helsinki.
Secure Systems Research Group - FAU Aspect Oriented Programming Carlos Oviedo Secure Systems Research Group.
Overview of AspectJ Aspect Oriented Software Development Seminar Technion presented by Oren Mishali.
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB JavaForum.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Iterators T.J. Niglio Computer & Systems Engineering Fall 2003 Software Design & Documentation Object Behavioral.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
AOP and Aspect C++ presentation by Igor Kotenkov based on presentation by Andreas Gal, Daniel Lohmann and Olaf Spinczyk.
EJB. Component Characteristics An enterprise Bean typically contains business logic that operates on the enterprise’s data. An enterprise Bean’s instances.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
Integrating Independent Components with On-Demand Remodularization based on OOPSLA 2002 paper by Mira Mezini Klaus Ostermann Prepared by Karl Lieberherr.
Aspect Oriented Programming Scott Nykl CSSE 411 Senior Seminar.
Tool support for crosscutting concerns of API documentation Michihiro Horie, Shigeru Chiba Tokyo Institute of Technology, Japan.
Expression evaluation E : S | C. S = int. C = Op E E. Op : A | M. A = “+”. M = “*”.
Modularizing Web Services Management with AOP María Agustina Cibrán, Bart Verheecke { Maria.Cibran, System and Software Engineering.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
AP/DJ AP: a generic technology DJ: a low-learning-curve implementation of AP.
Aspect Oriented Programming Gülşah KARADUMAN.
Schema Set getDefinedTypeNames() Set getUndefinedTypeNames() void addDef(Set def) void addUndef(Set undef, Set def) SchemaItem void addDef(Set def) void.
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.
1 Model Evolution with Aspect-oriented Mechanisms Naoyasu Ubayashi (Kyushu Institute of Technology) Tetsuo Tamai (University of Tokyo) Shinji Sano, Yusaku.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
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.
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.
Checking LoD in AspectJ Show the idea, not the details. How can we precisely express it in a programming language?
Aspect Oriented Development Alex Beatty.  Purpose  Cross-cutting Concerns  Join Points, Pointcuts, and Advices  Weaving  Invasive vs. Non-Invasive.
CSE 332: Design Patterns Review: Design Pattern Structure A design pattern has a name –So when someone says “Adapter” you know what they mean –So you can.
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.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
AOSD'04, Lancaster, UK 1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech) Shigeru Chiba (Tokyo Tech) Michiaki Tatsubori.
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.
1 An AOP Implementation Framework for Extending Join Point Models Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Hidehiko Masuhara(University.
Talk only to your friends that share the same concerns (Law of Demeter for Concerns) Midterm Review February 2004.
L’origine dei mali: le dipendenze tra componenti Stefano Leli 14° Workshop DotNetMarche Venerdì 16 aprile
Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing.
Callbacks and Interceptors. Contents  Session Beans Life Cycle  Interceptors.
Unit II-Chapter No. : 5- design Patterns
Crosscutting Capabilities for Java and AspectJ through DJ
MACS 2005 First International Workshop on the Modeling and Analysis of Concerns in Software Concern Management for Constructing Model Compilers -- Towards.
Behavioral Design Patterns
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
For John.
Demeter Aspects Who We Are Aspectual Collaborations
TIM 58 Chapter 8: Class and Method Design
By Ru Shen Department of Computer Science UAlbany, 2008
Aspect-Oriented Design and Patterns
ADAPTIVE PROGRAMMING Sezen ERDEM December 2005.
AP/DJ AP: a generic technology
Review: Design Pattern Structure
JAsCo an Aspect-Oriented approach tailored for
Lecture 21: Crosscutting Aspect-Oriented Programming Background
Better Separation of Crosscutting Concerns with Aspectual Components
LoD in AspectJ Karl Lieberherr.
Context Objects Evolution of object behavior Behavioral patterns
Lecture 8 Evolution of object behavior Behavioral patterns
APPCs revisited 2/25/2019 APPCs revisited.
Stateful Aspects in JAsCo
Aspect Oriented Software Design
Law of Demeter (LoD) 7/23/2019 LoD
Presentation transcript:

Adaptive Programming in JAsCo Wim Vanderperren | pag. 1

Adaptive Programming (1) Law of Demeter: a method should talk only to its friends: arguments and part objects (computed or stored) and newly created objects Example: class Test { Test2 test2; public void do() { test2.getTest3().start(5); } NOT GOOD JAsCoAP | pag. 2

Adaptive Programming (1) Law of Demeter: a method should talk only to its friends: arguments and part objects (computed or stored) and newly created objects Better Example: class Test2 { Test3 test3; public void do(int i){ test3.start(i); } class Test { Test2 test2; public void do() { test2.do(5); } BUT: “do” logic is spread over several classes now JAsCoAP | pag. 3

Adaptive Programming (2) Law of Demeter: a method should talk only to its friends: arguments and part objects (computed or stored) and newly created objects Dilemma: Crosscutting concerns (if follow) or Unmaintainable code (if not follow) AP is the solution to this dilemma JAsCoAP | pag. 4

Adaptive Programming (3)?  Save contents of DataStores to file … ClassA DS Visitor from ClassA to DataStore AP Option Class SaveVisitor { saveA(ClassA a); saveB(ClassB b); … } Class Save { save(ClassA a) { a.B.C.DataStore; a.F.E.Datastore; } DS Visitor Option 1 Option 2 Crosscutting Concerns Violates Law of Demeter ClassB ClassF Data- Store ClassC ClassD ClassE Data- Store JAsCoAP | pag. 5

Adaptive Programming (4) Traversal Strategy: Specifies the abstract traversal that has to be followed. Example: From Test to Test3 Adaptive Visitor: Implements the behavior itself Visits the concrete traversal as specified by the abstract traversal strategy. JAsCoAP | pag. 6

Structure-shy visitors Robustness wrt evolution of base program Advantages of AP Structure-shy visitors Robustness wrt evolution of base program Separation of concerns Complementary to all OO based approaches, even AOP Optimal visiting process JAsCoAP | pag. 7

Why combine AP & JAsCo? class DataStorePersistence extends Visitor { public void before(DataStore store) { if(changedPV(store)) { Writer writer = … writer.writeObject(store.getData()); } public boolean changedPV(DataStore s) { \\ true if changed since last visit What if we want to deploy AP visitors in a component- based context … AP visitors are already structure-shy. But, still refer to specific types and APIs! void backup(ClassA a) { ClassGraph cg = new ClassGraph(“a”); Strategy sg = new Strategy(“from ClassA to DataStore”); TraversalGraph tg = new TraversalGraph(sg, cg); tg.traverse(a, new DataStorePersistence()); } JAsCoAP | pag. 8

Represent Adaptive Visitors as regular aspect beans JAsCo AP: the idea Represent Adaptive Visitors as regular aspect beans Introduce a new kind of connector, called “traversal connector”, for instantiating an aspect bean as an adaptive visitor on a certain traversal strategy. JAsCoAP | pag. 9

Brief JAsCo Intro call, cflow, withincode, target class DataPersistence { hook Backup { Backup(triggeringmethod(..args)) { execution(triggeringmethod); } isApplicable() { // true when changed since last visit } before() { Writer writer = … writer.writeObject(getDataMethod()); } refinable Object getDataMethod(); Deploy Abstract method parameter call, cflow, withincode, target connector PersistenceConnector { DataPersistence.Backup hook = new DataPersistence.Backup( * DataStore.set*(*)); } Abstract pointcut Triggering condition around, around throwing, around returning, after, after throwing, after returning refining DataPersistence.Backup for DataStore { public Object getDataMethod() { DataStore d = thisJoinPointObject; return d.getData(); } JAsCoAP | pag. 10

Aspect Beans as AP visitors  An dedicated connector: traversal connector. from … bypassing … from … via … … Traversal Strategy traversalconnector BackupTraversal(“from ClassA to *”) { DataPersistence.Backup hook = new DataPersistence.Backup(visiting DataStore); hook.before(); } Object type to visit Advice to invoke & Precedence visiting * visiting Data* … public void backup(ClassA a) { BackupTraversal myBackup = BackupTraversal.getInstance(); myBackup.traverse(a); } hook1.before(); hook2.before(); hook2.after(); hook1.after(); Explicit invocation JAsCoAP | pag. 11

JAsCoAP: Precedence Strategies traversalconnector BackupTraversal("from system.Root to *") { DataPersistenceAspectBean.Backup backup = new DataPersistenceAspectBean.Backup(visiting DataStore) { public void getDataMethod(Object context) { DataStore store = (DataStore) context; return store.getData(); } }; Logger.FileLogger logger = new Logger.FileLogger(visiting *); logger.before(); backup.before(); JAsCoAP | pag. 12

Combining multiple AP visitors  How to combine the behavior of multiple AP visitors? Only execute if Save Visitor executed ClassA Save Visitor Save Visitor Log Visitor ClassB ClassF from ClassA to * Data- Store ClassC ClassD ClassE Data- Store But keep AP visitor implementation independent … JAsCoAP | pag. 13

JAsCoAP: Combination Strategies public class TwinCombinationStrategy implements CombinationStrategy { private Object hookA,hookB; TwinCombinationStrategy(Object a, Object b) { this.hookA=a; this.hookB=b; } HookList verifyCombinations(HookList list) { if(!list.contains(hookA)) list.remove(hookB); return list; JAsCoAP | pag. 14

JAsCoAP: Combination Strategies (2) traversalconnector BackupTraversal("from system.Root to *") { DataPersistenceAspectBean.Backup backup = new DataPersistenceAspectBean.Backup(visiting DataStore) { public void getDataMethod(Object context) { DataStore store = (DataStore) context; return store.getData(); } }; Logger.FileLogger logger = new Logger.FileLogger(visiting *); logger.before(); backup.before(); TwinCombinationStrategy twin = new TwinCombinationStrategy(backup,logger); addCombinationStrategy( twin); JAsCoAP | pag. 15

JAsCoAP: Advanced Traversal Strategies Bypassing: “from A bypassing C to B” via : “from A via C to B” ->Start,field,End : “from A via ->C,f,* to B” x A C f D B … E E g g JAsCoAP | pag. 16

Structure-shy visitors Robustness wrt evolution of base program Advantages of JAsCo AP Structure-shy visitors Robustness wrt evolution of base program Separation of concerns Increases Aspect Bean reusability Completely Abstract Adaptive Visitors represented as Aspect Beans Managing combined visiting behavior by Precedence&Combination strategies JAsCoAP | pag. 17

Exercises JAsCoAP | pag. 18