Stateful Aspects in JAsCo

Slides:



Advertisements
Similar presentations
Overloading Having more than one method with the same name is known as overloading. Overloading is legal in Java as long as each version takes different.
Advertisements

Towards a Standard Interface for Runtime Inspection in AOP Environments OOPSLA Workshop on Tool for AOSD, Seattle, November 2002 Katharina Mehner and Awais.
Formal Language, chapter 4, slide 1Copyright © 2007 by Adam Webber Chapter Four: DFA Applications.
Mahadevan Subramaniam and Bo Guo University of Nebraska at Omaha An Approach for Selecting Tests with Provable Guarantees.
CS 290C: Formal Models for Web Software Lecture 4: Implementing and Verifying Statecharts Specifications Using the Spin Model Checker Instructor: Tevfik.
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
An Overview of AspectJ Sabine Hauert. Today's Deserts  Whipped introduction served with its three berries syrup  Chocolate history soufflé  Design.
Overview of AspectJ Aspect Oriented Software Development Seminar Technion presented by Oren Mishali.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
Aspect-Oriented Software Development (AOSD) Tutorial #2 AspectJ Basics.
Aspect-Oriented Software Development (AOSD) Tutorial #2 AspectJ Basics.
More on AspectJ. aspect MoveTracking { private static boolean _flag = false; public static boolean testAndClear() { boolean result = _flag; _flag = false;
Finite Automata Costas Busch - RPI.
CS 1110 Final Exam: Review Session 2 Part 1 : Inheriting classes 1. Inheritance Facts 2. Constructors in Subclasses BREAK : 10 sec. Part 2 : Working with.
AOP and Aspect C++ presentation by Igor Kotenkov based on presentation by Andreas Gal, Daniel Lohmann and Olaf Spinczyk.
1 Thomas Cottenier 1,2, Aswin van den Berg 1, Tzilla Elrad 2 1 Software and System Engineering Research Lab, Motorola Labs 2 Concurrent Programming Research.
Spring core v3.x Prepared by: Nhan Le. History v3.0 Spring Expression Language Java based bean metadata v3.1 Cache Abstraction Bean Definition Profile.
Object Oriented Programming: Java Edition By: Samuel Robinson.
Polymorphism, Inheritance Pt. 1 COMP 401, Fall 2014 Lecture 7 9/9/2014.
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
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.
1 HARDCODING FINITE AUTOMATA Ernest Ketcha Ngassam Prof. Bruce W. Watson Prof. Derrick G. Kourie Department of Computer Science University of Pretoria.
POSL (Principles of Software Languages) Gr. Kyushu Institute of Technology, Japan Pointcut-based Architectural Interface.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
CCC: An Aspect-Oriented Intermediate Language on.Net Platform Yingfei Xiong and Feng Wan University of Electronic Science and Technology of China, China.
TRANSITION DIAGRAM BASED LEXICAL ANALYZER and FINITE AUTOMATA Class date : 12 August, 2013 Prepared by : Karimgailiu R Panmei Roll no. : 11CS10020 GROUP.
Virtual Support for Dynamic Join Points C. Bockisch, M. Haupt, M. Mezini, K. Ostermann Presented by Itai Sharon
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.
Inter-Type Declarations in AspectJ Awais Rashid Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
Mock objects.
CMSC 330: Organization of Programming Languages Finite Automata NFAs  DFAs.
CSC 212 Object-Oriented Programming and Java Part 2.
Aspect Oriented Development Alex Beatty.  Purpose  Cross-cutting Concerns  Join Points, Pointcuts, and Advices  Weaving  Invasive vs. Non-Invasive.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Threads and Singleton. Threads  The JVM allows multiple “threads of execution”  Essentially separate programs running concurrently in one memory space.
Rémi Douence, Thomas Fritz Nicolas Loriant, Jean-Marc Menaud Marc Ségura-Devillechaise, Mario Südholt OBASCO group EMN/INRIA An expressive aspect language.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
问题 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.
AOSD'04, Lancaster, UK 1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech) Shigeru Chiba (Tokyo Tech) Michiaki Tatsubori.
Computer Science 320 A First Program in Parallel Java.
SCoPE: an AspectJ Compiler for Supporting User-Defined Analysis-Based Pointcuts Tomoyuki Aotani Hidehiko Masuhara
EEL 5937 The Bond Agent System (1) EEL 5937 Multi Agent Systems Lecture 8, Jan 30, 2003 Lotzi Bölöni.
Chapter 13: Multithreading The Thread class The Thread class The Runnable Interface The Runnable Interface Thread States Thread States Thread Priority.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 1 Ahmed Ezzat.
Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing.
Fall 2004COMP 3351 Finite Automata. Fall 2004COMP 3352 Finite Automaton Input String Output String Finite Automaton.
Abstract classes and interfaces
Modular Software Development for Dealing with Uncertainty
Languages.
Exceptions, Interfaces & Generics
Java Byte IPC: Part 6-Summary
Lecture 9 Concepts of Programming Languages
CPSC 388 – Compiler Design and Construction
Aspect-Oriented Programming
Abstract classes and interfaces
null, true, and false are also reserved.
Non-Deterministic Finite Automata
Chapter Four: DFA Applications
JAsCo an Aspect-Oriented approach tailored for
LoD in AspectJ Karl Lieberherr.
Tonga Institute of Higher Education
Abstract classes and interfaces
Aspect Oriented Software Design
Aspect Oriented Programming
Adaptive Programming in JAsCo
Presentation transcript:

Stateful Aspects in JAsCo Wim Vanderperren | pag. 1

Natural Evolution of joinpoints: Stateful Aspects Natural Evolution of joinpoints: Static Dynamic (e.g. cflow) Stateful Stateful Aspects in JAsCo | pag. 2

Timing Aspect 1 class DynamicTimer { 3 private Vector<TimeListener> listeners = new Vector<TimeListener>(); 4 private long timestampbefore, timestampafter; 6 void addTimeListener(TimeListener aListener) { 7 listeners.add(aListener); 8 } 9 void removeTimeListener(TimeListener aListener) { 10 listeners.remove(aListener); 11 } 12 void notifyTimeListeners(Method method, long time) { 13 for (TimeListener listener : listeners) { 14 listener.timeStampTaken(method,time); 15 } 16 } 18 hook TimeStamp { 19 TimeStamp(timedmethod(..args)) { 20 execution(timedmethod); 21 } 22 before { 23 timestampbefore = System.currentTimeMillis(); 24 } 25 after { 26 timestampafter = System.currentTimeMillis(); 27 notifyListeners(thisJointPoint,timestampafter-timestampbefore); 28 } 29 } 30 } Stateful Aspects in JAsCo | pag. 3

Timing one method: But how to time a protocol? E.g. time between execution of a-b-c on ComponentX. 1 connector TimeConnector { 2 DynamicTimer.TimeStamp timer = 3 new DynamicTimer.TimeStamp (void ComponentX.a()); 4 timer.before(); 5 timer.after(); 6 } Stateful Aspects in JAsCo | pag. 4

Protocol Timing Aspect? 1 class ProtocolDynamicTimer extends DynamicTimer { 2 3 boolean methodaexecuted, methodbexecuted = false; 4 5 hook ProtocolMethodA { 7 ProtocolMethodA(methodA(..args)) { 8 execution(methodA); 9 } 10 before { 11 timestampbefore = System.currentTimeMillis(); 12 methodaexecuted = true; 13 } 14 isApplicable() { return !methodaexecuted; } 15 } 16 17 hook ProtocolMethodB { 18 ProtocolMethodB(methodB(..args)) { 19 execution(methodB); 20 } 21 before { 22 methodbexecuted = true; 23 } 24 isApplicable() { return methodaexecuted; } 25 } 26 27 hook ProtocolMethodC { 28 ProtocolMethodC(methodC(..args)) { 29 execution (methodC); 30 } 31 after { 32 timestampafter = System.currentTimeMillis(); 33 notifyListeners(method,timestampafter-timestampbefore); 34 methodaexecuted = false; methodbexecuted = false; 35 } 36 isApplicable() { return methodbexecuted; } 37 } 39 } connector TimeConnector { DynamicTimer.ProtocolMethodA timera = new DynamicTimer. ProtocolMethodA (void ComponentX.a()); DynamicTimer.ProtocolMethodB timerb = new DynamicTimer. ProtocolMethodB (void ComponentX.b()); DynamicTimer.ProtocolMethodC timerc = new DynamicTimer. ProtocolMethodC (void ComponentX.c()); } Stateful Aspects in JAsCo | pag. 5

Stateful Aspects: Motivation Protocol based aspects are rarely supported in current AOSD approaches (apart cflow). Result: protocol checking code is scattered over advices, poluting advice code… Is also not optimal, checks at all possible joinpoints while only a subset is required. Stateful Aspects in JAsCo | pag. 6

Example: Realize a more general protocol history condition than cflow. Stateful Aspects Allows specifying regular (=DFA based) hook triggering conditions in a hook’s constructor. Advices can be attached to any transition of the DFA, or all of them (global). Example: Realize a more general protocol history condition than cflow. Stateful Aspects in JAsCo | pag. 7

Timing Example Revisited 1 class ProtocolDynamicTimer extends DynamicTimer { 2 3 hook StatefulProtocolTimer { 4 5 long timestamp; 6 7 StatefulProtocolTimer(methodA(..args),methodB(..args),methodC(..args)) { 8 ATrans: execution(methodA) > BTrans; 9 BTrans: execution(methodB) > CTrans; 10 CTrans: execution(methodC) > ATrans; 11 } 12 13 before ATrans() { 14 timestamp=System.currentTimeMillis(); 15 } 16 after CTrans() { 17 long resultingtime = System.currentTimeMillis(); 18 notifyListeners(calledmethod,resultingtime-timestamp); 19 } 20 21 } 22 } Regular JAsCo Pointcuts for triggering the transition Transition Labels Stateful Pointcut Following Transitions to evaluate Attaching Advices to specific transitions Stateful Aspects in JAsCo | pag. 8

Timing Example Revisited static connector TimingConnector { perthread ProtocolDynamicTimer.StatefulProtocolTimer timer = new ProtocolDynamicTimer.StatefulProtocolTimer( void ComponentX.a()., void ComponentX.b(), void ComponentX.c() ); } Stateful Aspects in JAsCo | pag. 9

Advanced Pointcut Features Explicit start transitions start > XTrans; Starting with two transitions: start > XTrans || QTrans; two destination transitions: XTrans: execution(methodA) > YTrans || QTrans; no destination transition QTrans: execution(methodB) && !cflow(methodC); Stateful Aspects in JAsCo | pag. 10

Advices Multiple specific advices possible, one for each transition per before/around */after * Global advice works for all transitions isApplicable can also be global or specific isApplicable() { //global condition for all transitions // returns true if advices should be executed } isApplicable XTrans() { //local condition only relevant for the transition XTrans // returns true if advices should be executed for the XTrans transition advantages Stateful Aspects in JAsCo | pag. 11

Strict Protocols Per default, stateful aspects are non-strict, e.g. protocol a()-d()-b()-c() also matches timing aspect. When no intermediate transitions are allowed, use the strict keyword: strict: ATrans: execution(methodA) > BTrans; BTrans: execution(methodB) > CTrans; CTrans: execution(methodC) > ATrans; Stateful Aspects in JAsCo | pag. 12

Strict Protocols with Context Only strict with respect to a certain set of joinpoints. E.g. timing aspect does not accept intermediate transitions on ComponentX, on other classes is ok though. StatefulProtocolTimer(methodA(..args),methodB(..args),methodC(..args), context(..args)) { strict[execution(context)]: ATrans: execution(methodA) > BTrans; BTrans: execution(methodB) > CTrans; CTrans: execution(methodC) > ATrans; } Rejects: ComponentX.a() ComponentX.d() ComponentX.b() ComponentX.c() static connector TimingConnector { …. new ProtocolDynamicTimer.StatefulProtocolTimer( void ComponentX.a()., void ComponentX.b(), void ComponentX.c(), void ComponentX.*(*) ); } Accepts: ComponentX.a() Y.d() ComponentX.b() ComponentX.c() Stateful Aspects in JAsCo | pag. 13

Complement of a protocol Trigger advices on everything outside the protocol: COMPLEMENT StatefulProtocolTimer(methodA(..args),methodB(..args),methodC(..args)) { complement: ATrans: execution(methodA) > BTrans; BTrans: execution(methodB) > CTrans; CTrans: execution(methodC) > ATrans; } around complement() { throw new SecurityException(“this is not allowed on “+thisJoinPoint.getClass()); Stateful Aspects in JAsCo | pag. 14

Complement with Context Only complement with respect to a certain set of joinpoints. StatefulProtocolTimer(methodA(..args),methodB(..args),methodC(..args), context(..args)) { complement[execution(context)]: ATrans: execution(methodA) > BTrans; BTrans: execution(methodB) > CTrans; CTrans: execution(methodC) > ATrans; } d() in complement: ComponentX.a() ComponentX.d() ComponentX.b() ComponentX.c() static connector TimingConnector { …. new ProtocolDynamicTimer.StatefulProtocolTimer( void ComponentX.a()., void ComponentX.b(), void ComponentX.c(), void ComponentX.*(*) ); } No complement: ComponentX.a() Y.d() ComponentX.b() ComponentX.c() Stateful Aspects in JAsCo | pag. 15

Default: weaved at all possible joinpoints defined in the pointcut. Weaving A DFA (Deterministic Finite Automaton) executes the stateful aspect at run-time. Default: weaved at all possible joinpoints defined in the pointcut. Optionally, jumping aspect in cooperation with run-time weaver: only weaved at next joinpoints in protocol overhead of reweaving vs overhead of aspect applied at all Stateful Aspects in JAsCo | pag. 16