Aspect-Oriented Software Development (AOSD) Tutorial #8 Composition Filters.

Slides:



Advertisements
Similar presentations
METHOD OVERRIDING 1.Sub class can override the methods defined by the super class. 2.Overridden Methods in the sub classes should have same name, same.
Advertisements

Fields, Constructors, Methods
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
Overview of AspectJ Aspect Oriented Software Development Seminar Technion presented by Oren Mishali.
Lecture 27 Exceptions COMP1681 / SE15 Introduction to Programming.
Road Map Introduction to object oriented programming. Classes
Aspect-Oriented Software Development (AOSD) Tutorial #10 Interference among Aspects.
Aspect-Oriented Software Development (AOSD) Tutorial #5 Categories of Aspects – contd.; LTL properties formalization; Assume – guarantee specifications.
Aspect-Oriented Software Development (AOSD) Tutorial #4 Categories of Aspects.
Aspect-Oriented Software Development (AOSD) Tutorial #5 Categories of Aspects – contd.; LTL properties formalization.
Aspect-Oriented Software Development (AOSD) Tutorial #4 Categories of Aspects.
1 Based on slides by Gitit Amihud. 2 The Person class String firstName String lastName Date birthDate Address home setFirstName(String) String getFirstName()
Aspect-Oriented Software Development (AOSD) Tutorial #2 AspectJ Basics.
Aspect-Oriented Software Development (AOSD) Tutorial #8 Composition Filters.
Rigorous Fault Tolerance Using Aspects and Formal Methods Shmuel Katz Computer Science Department The Technion Haifa, Israel
Aspect-Oriented Software Development (AOSD) Additional Tutorial.
Aspect-Oriented Software Development (AOSD) Tutorial #6 Categories of Aspects – contd.; LTL properties formalization; Assume – guarantee specifications.
Building Java Programs Inner classes, generics, abstract classes reading: 9.6, 15.4,
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Aspect-Oriented Software Development (AOSD) Tutorial #5 Categories of Aspects – contd.; LTL properties formalization.
Aspect-Oriented Software Development (AOSD) Tutorial #3 AspectJ - continued.
C++ fundamentals.
Singleton Christopher Chiaverini Software Design & Documentation September 18, 2003.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Object-Oriented Software Testing. C-S 5462 Object-Oriented Software Testing Research confirms that testing methods proposed for procedural approach are.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
Aspect Oriented Programming Razieh Asadi University of Science & Technology Mazandran Babol Aspect Component Based Software Engineering (ACBSE)
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Aspect Oriented Programming Scott Nykl CSSE 411 Senior Seminar.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
The Java Programming Language
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
Cohesion and Coupling CS 4311
RIT Computer Science Dept. Goals l Inheritance l Modifiers: private, public, protected l Polymorphism.
Methods in Java. Program Modules in Java  Java programs are written by combining new methods and classes with predefined methods in the Java Application.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
Static Methods. 2 Objectives Look at how to build static (class) methods Study use of methods calling, parameters, returning values Contrast reference.
OOP in Java : © W. Milner 2005 : Slide 1 Java and OOP Part 2 – Classes and objects.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
CSE 143 Lecture 24 Advanced collection classes (ADTs; abstract classes; inner classes; generics; iterators) read 11.1, 9.6, , slides.
Session 04 Module 8: Abstract classes and Interface Module 9: Properties and Indexers.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Server-Side Java Mapping Copyright © ZeroC, Inc. Ice Programming with Java 6. Server-Side Java Mapping.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Exceptions Chapter 16 This chapter explains: What as exception is Why they are useful Java exception facilities.
Composition Filter – Part 2 איתי בן אליעזר נובמבר 2004.
Exceptions and Assertions Chapter 15 – CSCI 1302.
ODS – Introduction to Web Services and BPEL Vakgroep Informatietechnologie Web Services & BPEL Design of Distributed Software.
© 2001 TRESE Group, University of Twente TRESE e-tutorial series 02Software the evolution problems using CF Solving the evolution problems using Composition.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Interfaces and Inner Classes
COM S 228 Introduction to Data Structures Instructor: Ying Cai Department of Computer Science Iowa State University Office: Atanasoff.
Refactoring Agile Development Project. Lecture roadmap Refactoring Some issues to address when coding.
AOSD'04, Lancaster, UK 1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech) Shigeru Chiba (Tokyo Tech) Michiaki Tatsubori.
The Singleton Pattern (Creational)
Chapter 6 - More About Problem Domain Classes1 Chapter 6 More About Problem Domain Classes.
Basic Syntax อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 2.
Chapter 9: Continuing Classes By Matt Hirsch. Table Of Contents 1.Static Fields and Methods 2.Inheritance I. Recycle Code with Inheritance II. Overriding.
Lecture 6:Interfaces and Abstract Classes Michael Hsu CSULA.
Chapter 3: Using Methods, Classes, and Objects
A tree set Our SearchTree class is essentially a set.
Presented by Gitit Amihud
Object initialization: constructors
A tree set Our SearchTree class is essentially a set.
Behavioral Design Pattern
Chapter 9 Carrano Chapter 10 Small Java
Presentation transcript:

Aspect-Oriented Software Development (AOSD) Tutorial #8 Composition Filters

Aspect-Oriented Software Development (236608) 2 Today: Composition Filters Filter types Superimposition of filters Examples

Aspect-Oriented Software Development (236608) 3 Example: Social Security System Document flow: Creates client’s entry (claim document) in the system Forwards the request to the appropriate handler Evaluates client’s disablement Issues bank orders Communicates with clients

Aspect-Oriented Software Development (236608) 4 Social Security System – contd. Main classes in the system: Document – implemented by Claim Document Task Processor – implemented by all the handlers Document //fields //methods ClaimDocument //more fields //more methods

Aspect-Oriented Software Development (236608) 5 Social Security System – contd. TaskProcessor is implemented by all the handlers Overridden methods: processDocument, forwardDocument

Aspect-Oriented Software Development (236608) 6 Implement System Evolution by Composition Filters Task1: Adding documents protection. In the initial system, any clerk could edit any field in a document. We need to ensure the fields each clerk is able to edit are exactly the fields needed for his task. Solution: add message filters!

Aspect-Oriented Software Development (236608) 7 Documents Protection - Restrictions Part of the restrictions are as follows: “Payment” can invoke the functions (= treat the messages): putApprovedClaim approvedClaim(): Currency “MedicalCheck” can invoke the functions: putMedicalCheckData(medCData: DocumentData) medicalCheckData(): DocumentData The restrictions for the other modules are defined similarly.

Aspect-Oriented Software Development (236608) 8 Documents Protection Task concern ProtectedClaimDocument begin filterinterface documentWithViews begin internals document: ClaimDocument; externals // no externals defined by this class conditions inactiveRH; inactiveRD; inactiveMC; inactiveP; inactiveOH; methods activeTask(); inputfilters … outputfilters … end filterinterface DocumentWithViews; … // implementation in Java end concern ProtectedClaimDocument; Objects on which we work; created together with the filter Objects passed to the filter as parameters Conditions used to define the filters ( = boolean methods in implementation) Methods used to implement the filters Implementation Meaning: “the view … is NOT active”

Aspect-Oriented Software Development (236608) 9 Documents Protection Task –contd. The “Implementation” part: implementation in Java // for example class ProtectedClaimDocument { boolean inactiveRH() { return this.activeTask().class()!=RequestHandler }; boolean inactiveRD() { … }; boolean inactiveMC() { … }; boolean inactiveP() { … }; boolean inactiveOH() { … }; String activeTask() { … }; } end implementation The task currently performed Conditions used to define the filters

Aspect-Oriented Software Development (236608) 10 Documents Protection – Input Filters Which filter types do we need? –Error? –Substitution? –Send? –Dispatch? –Wait? –Meta? ✔ block unauthorized modifications ✘ ✘ ✘ ✘ ✔ Implement inheritance (from Document)

Aspect-Oriented Software Development (236608) 11 Documents Protection – Input Filters “inheritance”: inh:Dispatch = { inner.*, document.* }; “Error” Try1: viewP :Error = {inactiveP ~> {putApprovedClaim, approvedClaim} }; viewMC:Error = {inactiveMC ~> {putMedicalCheckData,medicalCheckData} }; // etc. for the other views Implement “Error” with the “=>” operator: protection: Error = { PaymentActive => {putApprovedClaim, approvedClaim}, MedicalCheckActive => {putMedicalCheckData, medicalCheckData}, … // etc. for the other views }; inner = implementation object document = internal instance of ClaimDocument exclusion operator enable operator what if inactiveP=false?

Aspect-Oriented Software Development (236608) 12 Documents Protection – contd. Order of the input filters = ? 1.Error(s) 2.Inheritance Output filters = ? No output filters needed

Aspect-Oriented Software Development (236608) 13 Superimposition Without superimposition: Each filter applies to one object only => Behavior crosscutting a number of methods within one object Superimposition: One filter applies to many objects Enables abstraction and (possibly multiple) instantiation

Aspect-Oriented Software Development (236608) 14 Superimposition – contd. abstraction instantitation filterinterfaces can be superimposed on this concern and on other concerns

Aspect-Oriented Software Development (236608) 15 Superimposition Syntax superimposition begin selectors Set1 = {…} Set2 = {…} … filterinterfaces Set1 <- concern1::filterinterface1; Set2 <- concern2::filterinterface2; … concern4::Set4 <- concern3::filterinterface3; end superimposition; For each superimposed filterinterface, define the set of its join-points join point selectors (abstract), define sets of concerns name of concern in which it is defined (if in the current concern, then “self” or empty) objects, methods and conditions can be superimposed in the same way

Aspect-Oriented Software Development (236608) 16 Task2: Adding Logging Assume a workflow control has been added the system The goal: monitor the process, detect the bottlenecks and reschedule and/or reallocate the resources, if necessary Implementation: register all the interactions among objects

Aspect-Oriented Software Development (236608) 17 Adding Logging – Implementation Add the class Logger. Main functionality: loggingEnabled – activate the logging loggingDisabled – deactivate the logging log(message) – extract the necessary info Additional functionality – retrieve information from the log

Aspect-Oriented Software Development (236608) 18 Logging – Implementation (contd.) concern Logging begin // introduces centralized logger filterinterface notifyLogger begin // this part declares the crosscutting code externals logger : Logging; // *declare* a shared instance of this concern internals logOn : boolean; // created when the filterinterface is imposed methods loggingOn(); // turn logging for this object on logginOff(); // turn logging for this object off log(Message); // declared here for typing purposes only conditions … // to be defined inputfilters … // to be defined outputfilters … //not needed end filterinterface notifyLogger; … end concern Logging;

Aspect-Oriented Software Development (236608) 19 Logging – Implementation (contd.) filterinterface logger begin externals //not needed internals //not needed methods log(Message); // various methods to retrieve info. from the log inputfilters disp : Dispatch = { inner.* }; outputfilters //not needed end filterinterface logger; accept all methods implemented by the object to which the logger is applied

Aspect-Oriented Software Development (236608) 20 Logging – Implementation (contd.) filterinterface notifyLogger begin // this part declares the crosscutting code externals logger : Logging; // *declare* a shared instance of this concern internals logOn : boolean; // created when the filterinterface is imposed methods loggingOn(); // turn logging for this object on logginOff(); // turn logging for this object off log(Message); // declared here for typing purposes only conditions LoggingEnabled; inputfilters logMessages : Meta = { LoggingEnabled=>[*]logger.log }; dispLogMethods : Dispatch = { loggingOn, loggingOff }; end filterinterface notifyLogger; if logging is enabled… log every message is the order correc t?

Aspect-Oriented Software Development (236608) 21 Logging – Implementation (contd.) concern Logging begin … superimposition begin selectors allConcerns = { *!=Logging }; conditions allConcerns <- LoggingEnabled; filterinterfaces allConcerns <- notifyLogger; self <- logger; end superimposition; … end concern Logging; everything except instances of Logging the applicability of Logging should be defined separately for each concern other than Logging Every concern (except for Logging) is crosscut by notifyLogger So that the logger will be able to retrieve info from the log…

Aspect-Oriented Software Development (236608) 22 Logging – Implementation (contd.) concern Logging begin … // the only part left: implementation in Java class LoggerClass { boolean LoggingEnabled() { return logOn }; void loggingOn() { logOn:=true; }; void loggingOff() { logOn:=false; }; void log(Message msg) { … }; // get information from message and store } end implementation end concern Logging; Where is “fire” of the Meta filter? “fire” is here…

Aspect-Oriented Software Development (236608) 23 HW1 – comments Each aspect should be defined separately, in a separate class (and, probably, in a separate file)! Modularity is important! Is this a good comment? “This pointcut does something (reduces the fractions, etc.)” - No! The advice does the action, and not the pointcut.

Aspect-Oriented Software Development (236608) 24 Rational Exam (reminder) private void doExam() { while (true) { r1 = randomRational(); r2 = randomRational(); result = r1.add(r2); answer = getAnswer(r1, r2); if (answer == null) break; checkAnswer(answer, result); } public static void main(String[] args) { RationalExam exam = new RationalExam(); exam.doExam(); }

Aspect-Oriented Software Development (236608) 25 HW1 – comments Is this a correct pointcut for Reduction aspect? pointcut createRational(int x, int y): (args(x,y) && call(Rational.new(..)) && !cflow(call(* RationalExam.getAnswer(..)))); How to refine it? For example, define the pointcut to catch the call to the “getAnswer” function from “doExam”, and then reduce the parameters in the advice Catches all the non-user-given fractions creations, and not only the fractions that appear in the questions of the exam!