7. Example of crosscutting concerns Display Figure FigureElement * Point Line getX() getY() getP1 setP1 DisplayUpdating setX(int) setY(int) setP1(Point) setP2(Point) 2 The red box is drawn around every method that must implement this concern DisplayUpdating fits neither inside of nor around the other boxes in the figure DisplayUpdating cuts across the other boxes
8.
9.
10.
11. Examples of how aspects cross-cut components We wanted to implement a distributed digital library that stores documents in many forms and provides a wide range of operations on those documents application components aspects digital database, minimizing network Library printers, traffic, services synchronization constraints, failure handling
12.
13.
14.
15.
16.
17.
18.
19. AOP technologies example Relevant aspects in TCS Aspect It refers to how the simulated entities should run Relationships Synchronization Scheduling It basically involves access to shared variables and race condition Description It works together with scheduling It works together with synchronization
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33. AspectJ example Aspect SimpleTracing { pointcut traced() : call (void Display.update () ) || call (void Display.repaint (..) ); before() : traced () { println(“Entering:” + thisJoinPoint); } void println (String str) { <write to appropriate stream> } } Traced identifies calls to several key methods on Display Before advice on this pointcut uses a helper method of the aspect to print a message Advice uses the thisJoinPoint special variable to an object that describes the current join point