Download presentation
Presentation is loading. Please wait.
1
Aspects at the Design Level
SNU., RTOSLAB. Jiyong Park
2
Contents Modeling Aspect Mechanisms Representing aspect in UML
The big picture of our framework Limitations of existing methods Proposed better methods Conclusion
3
Modeling Aspect Mechanisms
Modular Crosscutting in Aspect-Oriented Mechanisms Hidehiko Masuhara – University of Tokyo Gregor Kiczales – University of British Columbia ECOOP 2003
4
Contents Brief descriptions of four aspect mechanisms
Pointcut, Advice Traversal Specification Class hierarchy composition Open class Model of each mechanisms
5
Four Different Aspect Mechanisms
Pointcut, Advice – AspectJ Traversal specification – Demeter, DemeterJ, DJ Class hierarchy composition – Hyper/J Open class – AspectJ
6
Pointcut, Advice execute display.update() whenever after set*() is called Figure FigureElement 1 * elements: List display: Display Point Line x: int y: int 2 p1: Point p2: Point getX(void): int getY(void): int setX(int x): void setY(int x): void getX(void): int getY(void): int setP1(Point p1): void setP2(Point p2): void
7
Pointcut, Advice Advice: additional implementation
Pointcut: the location that the advice is to be inserted after (FigureElement fe): call(void FigureElement+.set*(..)) && target(fe) { fe.display.update(fe); } Figure FigureElement 1 * elements: List display: Display Point Line x: int y: int 2 p1: Point p2: Point getX(void): int getY(void): int setX(int x): void setY(int x): void getX(void): int getY(void): int setP1(Point p1): void setP2(Point p2): void DisplayUpdating after(): call(void FigureElement+.set*(..)) || call(void FigureElement.moveBy(int, int)) { Display.update(); }
8
Traversal Specification
find all persons waiting at any bus stop on a bus route busStops BusRoute BusStopList OO solution: one method for each green class buses 0..* BusStop BusList waiting 0..* passengers PersonList Bus Person 0..*
9
Traversal Specification
from BusRoute through BusStop to Person busStops BusRoute BusStopList buses 0..* BusStop BusList waiting 0..* passengers PersonList Bus Person 0..*
10
Traversal Specification
Build a object graph (based on reachability) at runtime Traversal specifiction: where to navigate Visitor: what to do before and after certain object is visited String WPStrategy=“from BusRoute through BusStop to Person” // Prepare the traversal for the current class graph ClassGraph classGraph = new ClassGraph(); TraversalGraph WPTraversal = new TraversalGraph (WPStrategy, classGraph); int r = aBusRoute.countPersons(WPTraversal);
11
Traversal Specification
root of the traversal class BusRoute { int countPersons(TraversalGraph WP) { Integer result = (Integer) WP.traverse(this, new Visitor(){ int r; public void before(Person host){ r++; } public void start() { r = 0;} public Object getReturnValue(){return new Integer(r);} } ); return result.intValue();
12
Traversal Specification
DJ Java Library (uses Reflection) Enables aspect programming in pure Java By Northeastern University
13
Class Hierarchy Composition
Meta-Program (How to weave) Source A Source A+B weaver Source B
14
bracket “{Point,Line}”.”set*” after Observable.moved($OperationName);
Program A Program B Figure FigureElement 1 * elements: List display: Display Point Line Observable x: int y: int 2 p1: Point p2: Point display: Display moved(): void { display.update(); } getX(void): int getY(void): int setX(int x): void setY(int x): void getX(void): int getY(void): int setP1(Point p1): void setP2(Point p2): void Meta-Program mergeByName; bracket “{Point,Line}”.”set*” after Observable.moved($OperationName);
15
Open Class Locate method or field declaration outside the textual body of the class declarion Synonym introduction (by AspectJ) inter-type declaration Common use Solve versions of the visitor problem class DisplayMethods { void Point.draw() { Graphics.drawOval(…);} void Line.draw() { Graphics.drawLine(…);} }
16
What is crosscutting structure ?
program A and B crosscut each other = set of join points identified by program A and B is not a subset of the other Program A Weaved Program Program B join point
17
Modeling Framework <X, XJP, A, AID, AEFF, AMOD, B, BID, BEFF, BMOD, META> A, B: language that input program is written X: result of domain weaving process XJP: join points in X AID, BID: means of identifying join points AEFF, BEFF: means of effecting semantics at identified join points AMOD: BMOD: units of modularity META: optional meta-language for parameterizing the weaving process Program A Weaver Program X Program B Meta program
18
Modeling Framework kind of join points kind of join points
19
Pointcut, Advice class aspect execution method call field set/get
object instantiated
20
Traversal Specification
object graph class traversal specification & visitor
21
Class Hierarchy Composition
combined program class method declaration field declaration class declaration meta program
22
Open Class class class open class method declaration field declaration
class declaration
23
Conclusion Pointcut, Advice of AspectJ is most popular
But, other mechanisms can give some insight Class hierarchy composition seems to be the most natural way
24
Our Aspect Weaving Framework
25
Key Ideas Automatically generate ‘weaver’ described by meta-model transform specification Represent aspects in graphical way
26
Key Idea 1: How to weave aspect ?
metamodel of aspectJ model transformation (aspectJ Java) metamodel of Java metamodel model aspectJ program aspect weaver Java Program implementation oriented (traditional) approach intermediate stage metamodel of aspect program model tr. generic object metamodel model tr. metamodel of Java metamodel model code gen aspect program Generic object program Java Program design oriented (our) approach
27
Comparision Limitations of implementation oriented approach
Weaver is dependent on language Hard to modify weaving process Our design oriented approach Intermediate model is introduced (generic object program) [generic object program implemention program] is naïve [aspect program generic object program], which is weaving process, is graphical
28
Related Work By Hidehiko Masuhara & Gregor Kiczales
29
Incorporating Aspects into the UML
Mark Basch, Arturo Sanchez Department of Computer and Information Science, University of North Florida International Conference on Aspect-Oriented Software Development (AOSD), 2003 From AOP to UML – A Bottom-Up Approach Mohamed Mancona Kande, Jorg Kienzle and Alfred Strohmeier Software Engineering Laboratory Swiss Federal Institute of Technology Lausanne Workshop on Aspect-Oriented Modeling with UML (as part of the AOSD 2003)
30
Contents UML is not suitable for model aspect Example Extension to UML
31
Using UML for OO Modeling
Well supported public class Account { private int balance = 0; public void withdraw (int amount) {…}; public void deposit (int amount) {…}; public int getBalance() {…}; } public class Customer { public String name; … a.withdraw(50); } (dynamic structure) (static structure)
32
Using UML for Aspect-Oriented Modeling
Logging aspect: all method calls made by customers on an account object generates logs Not well supported public aspect Logging { private PrintWriter Account.myLog; public void Account.setLog(String fileName) { myLog = new Log(fileName); myLog.println(“This is the logfile for account “+ this); } pointcut MethodCall(Customer c, Account a): call (public * Account.*(..)) && this(c) && target(a); after (Customer c, Account a): MethodCall(c,a) { a.myLog.println(c+” called “+ thisJoinPoint.getSignature().getName()); a.myLog.flush();
33
Using UML for Aspect-Oriented Modeling
34
Problems of the Previous Modeling
Aspect is scattered throughout the diagrams The two diagrams are inconsistent (Interceptor class) pointcut, introduction, advice are not explicitly modeled … Abstraction inversion In implementation: logging code is seperated In design: logging design is scattered
35
Modeling Aspect in UML Extending existing UML
Using stereotype, tag, … Confusing Introduce new modeling element Clear
36
Extending Existing UML
Designing Aspect-Oriented Crosscutting in UML Dominik Stein, Stefan Hanenberg, and Rainer Unland
37
Extending Existing UML
From AOP to UML – A Bottom-Up Approach Mohamed Mancona Kandé, Jörg Kienzle and Alfred Strohmeier
38
Extending Existing UML
A UML Notation for Aspect-Oriented Software Design Renaud Pawlak, Laurence Duchien, …
39
Introduce New Modeling Element
Incorporating Aspects into the UML Mark Basch, Arturo Sanchez New elements join points aspects
40
1. Aspect Packages join points are modeled outside of aspect and component package
41
2. Class Diagrams for Aspects
Within aspect package To show which component classes are cross-cut by the aspect
42
3. Interaction Diagrams for Aspects
Interaction between component and aspect
43
3. Interaction Diagrams for Aspects
Sequence inside the aspect
44
Future Work Bring new UML notation into our framework
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.