More on AspectJ. aspect MoveTracking { private static boolean _flag = false; public static boolean testAndClear() { boolean result = _flag; _flag = false;

Slides:



Advertisements
Similar presentations
AspectWerkz 2 - and the road to AspectJ 5 Jonas Bonér Senior Software Engineer BEA Systems.
Advertisements

A Brief Introduction to Aspect-Oriented Programming Zhenxiao Yang.
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 JAC : Aspect Oriented Programming in Java An article review by Yuval Nir and Limor Lahiani.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Modularization.
An Overview of AspectJ Sabine Hauert. Today's Deserts  Whipped introduction served with its three berries syrup  Chocolate history soufflé  Design.
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.
University of British Columbia Software Practices Lab Fluid AOP Join Point Models Terry Hon Gregor Kiczales.
An Untyped Calculus of Aspect- Oriented Programs Radha Jagadeesan Alan Jeffrey James Riely DEPAUL UNIVERSITY, CHICAGO.
AOP: Does It Make Sense? The Case of Concurrency and Failures by Jörg Kienzle and Rachid Guerraoui Sibylle Aregger & Antonia Schmidig Presentation based.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Denotational Semantics Syntax-directed approach, generalization of attribute grammars: –Define context-free abstract syntax –Specify syntactic categories.
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales.
Categories of Aspects Shmuel Katz Computer Science Department The Technion Haifa, Israel.
Categories of Aspects Shmuel Katz Computer Science Department The Technion Haifa, Israel.
Rigorous Fault Tolerance Using Aspects and Formal Methods Shmuel Katz Computer Science Department The Technion Haifa, Israel
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
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.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Debugging Support.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Aspect Oriented Programming Gülşah KARADUMAN.
A Meta-Level Specification and Profile for AspectJ in UML Joerg Evermann School of Information Management Victoria University of Wellington.
A Distributed Aspect-Oriented System for J2EE Applications Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) Background - As benefits.
Design Rules for Increasing Modularity with CaesarJ Carlos Eduardo Pontual Advisor: Paulo Borba 17/06/2010.
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
Categories of Aspects Shmuel Katz Computer Science Department The Technion Haifa, Israel.
CMP-MX21: Lecture 4 Selections Steve Hordley. Overview 1. The if-else selection in JAVA 2. More useful JAVA operators 4. Other selection constructs in.
Aspect-Oriented Programming and Modular Reasoning G. KiczalesM. Mezini Presented by Alex Berendeyev.
SE424 Languages with Context A Block Structured Language.
Inter-Type Declarations in AspectJ Awais Rashid Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
Slicing AspectJ Woven Code Luca Cavallaro Mattia Monga Antonio Castaldo D'Ursi Davide Balzarotti Politecnico di Milano.
AspectJ – AOP for Java Tom Janofsky. Instructor at Penn State Abington Consultant with Chariot Solutions JUG Member.
Topics for exam in AOSD Basic concepts: tangling, scattering, joinpoint, advice, cross-cutting, weaving AspectJ: syntax, pointcut notations, around, proceed,
Object-Oriented Programming Chapter Chapter
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
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.
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.
CSSE501 Object-Oriented Development. Chapter 10: Subclasses and Subtypes  In this chapter we will explore the relationships between the two concepts.
R R R A Brief Introduction to Aspect-Oriented Programming.
CSC450 Software Engineering Devon M. Simmonds University of North Carolina, Wilmington 1.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
Recap Introduction to Inheritance Inheritance in C++ IS-A Relationship Polymorphism in Inheritance Classes in Inheritance Visibility Rules Constructor.
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.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
University of British Columbia Software Practices Lab Uniform Support for Modeling Crosscutting Structure Maria Tkatchenko Gregor Kiczales Work supported.
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.
1 Aspectual Caml an Aspect-Oriented Functional Language Hideaki Tatsuzawa Hidehiko Masuhara Akinori Yonezawa University of Tokyo.
PPL 2004, Gamagori, AICHI1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech, Japan) Shigeru Chiba (Tokyo Tech, Japan)
Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing.
Programming with ANSI C ++
Java Primer 1: Types, Classes and Operators
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
Chapter 3: Using Methods, Classes, and Objects
Discussion with Gregor Kiczales at UBC
Aspect Validation: Connecting Aspects and Formal Methods
A Brief Introduction to Aspect-Oriented Programming
Languages and Compilers (SProg og Oversættere)
Classes, Objects and Methods
Aspect Oriented Software Design
Threads and concurrency / Safety
Presentation transcript:

More on AspectJ

aspect MoveTracking { private static boolean _flag = false; public static boolean testAndClear() { boolean result = _flag; _flag = false; return result; } pointcut moves(): execution(void Line.setP1(Point)) || execution (void Line.setP2(Point)) || execution (void Point.setX(int)) || execution (void Point.setY(int)); static after(): moves() { _flag = true; } multi-class aspect aspect defines a special class that can crosscut other classes

multi-class aspect with context aspect MoveTracking { private static Set _movees = new HashSet(); public static Set getMovees() { Set result = _movees; _movees = new HashSet(); return result; } pointcut moves (): execution(void Line.setP1(Point)) || execution (void Line.setP2(Point)) || execution (void Point.setX(int)) || execution (void Point.setY(int)); pointcut movesWhat(FigureElement figElt): this(figElt) && moves(); after(FigureElement fe): movesWhat(fe) { _movees.add(fe); } }

Advice Composition Ordering Advice that applies to the same join point is executed sequentially Precedence rules: if advice A has precedence over advice B, A can be executed before B. explicit declaration: " declare precedence: AspectA, AspectB; "

Advice Composition 2 If advice comes from different aspects: follow declare precedence rules subaspects have precedence over superaspects otherwise undefined If advice comes from the same aspect: the one that appears earlier in the aspect specification has precedence over others further: around1  before  body  after returning  after throwing  after  around2

Inter-type declarations Previously called static model introduction Aspects make declarations that relate to other types (classes): inter-type member declarations methods & fields (but can be seen as local to the aspect) no full pointcuts can be used declare parents: change inheritance/interface hierarchy declare error/warning: when a certain join point is encountered.

Aspect Instantiation advice always executes in the context of an aspect instance by default, each aspect is a singleton; the same instance used throughout the program aspects may be declared as: perthis(Pointcut): for each executing object pertarget(Pointcut): for each target object percflow(Pointcut): for each entrance to a cflow...

Operational Semantics of weaving A model of execution, not necessarily what the compiler will really do At compilation, all of the base system and the aspects are available. Mark all potential join points in the code (called shadow join points ) Begin executing until first shadow is reached, check if it is a real joinpoint If so, continue executing the advice code, until the next shadow is reached, etc…

Operational semantics (cont.) A rolling semantics of aspects Can’t identify all real joinpoints in advance, even if we have the state execution graph of the underlying system Can even have joinpoints of an aspect within its own advice! Sometimes, simplifications are possible, but general analysis is difficult

Summary of AspectJ Dynamic execution model (joinpoints) pointcutsbehavior (advice) Base level Aspect Level Classes (objects) Aspects (aspect instances) (binding)

AspectJ Concepts what are the join points points in runtime call graph class members means of identifying join points pointcuts member signatures (plus …) means of specifying semantics at join points advice define members dynamic JPM (points in execution) static JPM (intertype decls)

Evaluation of AspectJ Strong points + well-integrated in Java (including typing) + single language (not multiple ADLs) + many powerful constructs + addresses crosscutting concerns ‘semantic-based’ queries wildcards + offers imposition of behavior + pointcut composition is supported + advice composition is possible, but...

Evaluation of AspectJ Limitations NB: in programming language design, a limitation is not always a drawback! - Advice constructs and ordering are complicated but limited - Reuse of aspects is primitive/restricted - Aspects are statically applied - No (few) joinpoints in advice I.e. mostly an ‘a-symmetrical model' - Composability of aspects is sole responsibility of the programmer(s) !! due to the full expression power within advice

Categories of Aspects Not all aspects are equally problematic Usually, aspects do not add joinpoints within their advice, especially recursively Often syntactic checks can determine the category, using dataflow Interesting properties of systems hold automatically for augmented systems with some categories of aspects

Spectative aspects Do not affect values of variables/fields, or the continuation of execution of the underlying system to which they are woven Can add local fields, use values from the underlying system for internal computation Must properly terminate with no exceptions Examples: Logging, monitoring for debugging, performance evaluation, gathering statistics, GUI updating (when the GUI is local to the aspect)

Identification of Spectative Use dataflow to see that no assignments are made to parameters that correspond to fields/variables of the underlying system Determine that the advice terminates (usually straight-line code) Claim: Almost all properties of the underlying system still hold in the augmented one Exceptions: real-time and next-state properties

Regulative aspects Do not change values of underlying, but can prevent some continuations Otherwise like spectative Strengthen conditions for some operations Examples: password authorization, restrict some methods to classes of users, impose scheduling conditions that restrict orderings Safety properties are maintained after weaving

Weakly invasive aspects CAN change values of underlying fields/variables, CAN redirect control, skip BUT, will return to a state already reachable in the underlying system (when the aspect variables are ignored) Means that the continuation will be one previously possible (until the next pointcut) Examples: Rollback of transactions, a discount policy, …

Strongly invasive Most general aspects…like weakly invasive, but CAN return to a state never possible in the underlying system Means that the underlying code now executes in a new context, and may do unexpected things Makes modular analysis/verification more difficult Examples: Semaphores extended to negative values, breaking invariants of the underlying system