1 / 69

Motorola WEAVR : Aspect-Oriented Modeling in TAU

Motorola WEAVR : Aspect-Oriented Modeling in TAU. Thomas Cottenier 1,2 , Aswin van den Berg 1 , Tzilla Elrad 2 1. Software & Systems Engineering Lab, Motorola Labs 2. Illinois Institute of Technology. Outline. Aspect-Oriented Software Development Aspect-Oriented Programming

valora
Download Presentation

Motorola WEAVR : Aspect-Oriented Modeling in TAU

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Motorola WEAVR:Aspect-Oriented Modeling in TAU Thomas Cottenier1,2, Aswin van den Berg1, Tzilla Elrad2 1. Software & Systems Engineering Lab, Motorola Labs 2. Illinois Institute of Technology

  2. Outline • Aspect-Oriented Software Development • Aspect-Oriented Programming • Aspect-Oriented Modeling and Model Weaving • The Motorola WEAVR add-in • A Profile for modeling Aspects in UML 2.0 • An Agent for visualizing Joinpoints and Analyze Joinpoint Effects • An Agent for weaving Aspects in models • An Agent for simulating woven models in the Model Verifier • An Agent for decomposing the generated traces • Conclusions

  3. Models Models@runtime Aspect-Oriented Programming Source Code 1990’s Object Oriented Programming Procedural Programming 1980’s Aspect-Oriented Software Development Aspect-Oriented Software Development Evolution of Software Design: Monolithic → Modular Abstraction Focus only on relevant properties Decomposition Divide software into separately named and addressable modules Encapsulation Group related things together. InformationHiding Hide implementation details from the outside Separation of Concerns Ensure that each module only deals with one concern - Low Coupling among the modules - High Cohesion within one module Metamodeling 2000’s Model-Driven Engineering

  4. Aspect-Oriented Software DevelopmentGood Modularity Socket creation in Tomcat - fits nicely into one package (3 classes)

  5. Aspect-Oriented Software DevelopmentGood Modularity Class Loading in Tomcat - mostly in one package (9 classes)

  6. Aspect-Oriented Software DevelopmentPoor Modularity Logging in Tomcat - scattered across the packages and classes - error handling, security, business rules, …

  7. Display * Figure FigureElement getX() getY() setX(int) setY(int) getP1() setP1() setP1(Point) setP2(Point) Point Line 2 Aspect-Oriented Software DevelopmentCrosscutting Concerns class DisplayTracker { static void updatePoint(Point p){ this.display(p); .... } static void updateLine(Line l){ this.display(l);.... } } DisplayTracking class Point { void setX(int x) { DisplayTracker.updatePoint(this); this.x = x; } } class Line { void setP1(Point p1) { DisplayTracker.updateLine(this); this.p1 = p1; } }

  8. Aspect-Oriented Software DevelopmentCrosscutting Concerns Display class Tracer { static void traceEntry(String str){ System.out.println(str); } static void traceExit(String str){ System.out.println(str); } } * Figure FigureElement 2 getX() getY() setX(int) setY(int) getP1() setP1() setP1(Point) setP2(Point) Point Line Tracing class Point { void setX(int x) { Tracer.traceEntry(“Entry Point.set”); this.x = x; Tracer.traceExit(“Exit Point.set”); } } class Line { void setP1(Point p1) { Tracer.traceEntry(“Entry Line.set”); this.p1 = p1; Tracer.traceExit(“Exit Line.set”); } }

  9. Aspect-Oriented Software DevelopmentCrosscutting Concerns Scattering In a given implementation, the code for a concern is spread out. Single concern affects multiple modules. Tangling Multiple concerns are interleaved in a single module Crosscutting Concern The inherent structure of the concern can not be modularized in the decomposition mechanism of the language (Objects or procedures), because it follows different composition rules. class Point { void setX(int x) { Tracer.traceEntry(“Entry Point.set”); DisplayTracker.updatePoint(this); this.x = x; Tracer.traceExit(“Exit Point.set”); } }

  10. Aspect-Oriented Software DevelopmentCrosscutting Concerns • Auxiliary concerns are scattered and tangled Synchronization, Real-time constraints, Error-checking, Object interaction constraints, Memory management, Persistency, Security, Caching, Logging, Monitoring, Testing, Domain specific optimization • 80% of problems come from this 20% of code • Inflexibility: hard to change/maintain have to find all the code involved and be sure to change it consistently • Redundancy: same fragment of code in many places Leads to inconsistency • Incomprehensibility: can’t see the forest for the trees

  11. Aspect-Oriented Software DevelopmentThe AOSD idea • crosscutting is inherent in complex systems • crosscutting concerns • have a clear purpose • have a natural structure • let’s capture the structure of crosscutting concerns explicitly • in a modular way • with linguistic and tool support

  12. Aspect-Oriented Software DevelopmentAspects Goal of AOSD Enable the modular (not scattered) implementation of crosscutting concerns. Aspect Explicit abstraction for representing crosscutting concerns Aspect-Oriented Programming Language that provides mechanisms to capture aspects Aspect Weaver Composition mechanism that coordinates aspects with the rest of the code.

  13. Aspect-Oriented ProgrammingAspect-Oriented Language Elements • join point (JP) model certain principled points in program execution such as method calls, field accesses, and object construction • means of identifying JPs picking out join points of interest (predicate) pointcuts: set of join points • means of specifying behavior at JPs what happens advice declarations pointcut traced(): call(* Line.*) || call(* Point.*); before(): traced() { println(“Entering:” + thisjoinpoint); }

  14. setY(int) setX(int) setY(int) setX(int) Aspect-Oriented ProgrammingAspect-Oriented Language Elements Joinpoints certain principled points in program execution such as method calls, field accesses, and object construction - method execution - method call - field get & set - exception handler execution - static & dynamic initialization - … :Line end1:Point end2:Point moveBy(int, int) moveBy(int, int) moveBy(int, int)

  15. Aspect-Oriented ProgrammingAspect-Oriented Language Elements Pointcuts: Queries over Joinpoints - filters picking out join points - primitive and user-definable - composable with &&, ||, ! pointcut moves(): call(void Line.setP1(Point)) || call(void Line.setP2(Point)) || call(void Point.setX(int)) || call(void Point.setY(int)) || call(void FigureElement.incrXY()); pointcut traced(): call(* Line.*) || call(* Point.*);

  16. Aspect-Oriented ProgrammingAspect-Oriented Language Elements Advice • code body attached to a pointcut • code runs at every join point picked out by a pointcut • after advice runs after the computation of a join point (both returning normally and throwing an exception) after(): moves() { Display.update(); } before(): (sets(int Point.x)) && !withincode(void Point.setX())) || (sets(int Point.y)) && !withincode(void Point.setY())) {throw new AccessDeniedException(); }

  17. Aspect-Oriented ProgrammingAspect-Oriented Language Elements An Aspect is a special type that crosscuts other types aspect MoveCounting { int count = 0;pointcut moves(): call(void Line.setP1(Point)) || call(void Line.setP2(Point)) ||call(void Point.setX(int)) || call(void Point.setY(int)); after(): moves() && !cflowSub(moves()) { count++; } }

  18. Aspect-Oriented Modeling • Address Crosscutting Concerns in Behavioral Models • Abstract away from pervasive implementation details • Model-Driven Architecture: Aspect specify a Model Transformation

  19. Aspect-Oriented Modeling

  20. Crosscutting Concerns in Models

  21. Models Source Code Coordination of Crosscutting Concerns in Models TAU + WEAVR Components SIP Blog IPv6 Crosscutting Concern weaving Security Fault Tolerance Data Logging TAU Code Generators

  22. Coordination of Crosscutting Concerns in Models Models Source Code IPv6 SIP Blog TAU + WEAVR SIP Blog IPv6 Security Fault Tolerance Data Logging TAU Code Generators Translating to: C, C++, C#, Java, … Finalized Components

  23. Coordination of Crosscutting Concerns in Models WEAVR Model weaving Engine Resource Initialization Aspect Initialization Exception Handling Aspect

  24. The Motorola WEAVR add-in • A Profile for modeling Aspects in UML 2.0 • An Agent for visualizing Joinpoints and Analyze Joinpoint Effects • An Agent for weaving Aspects in models • An Agent for simulating woven models in the Model Verifier • An Agent for decomposing the generated traces

  25. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 Extensions to UML 2.0 for Aspect-Oriented Modeling. 3 different functions: • Define the WEAVR Aspect-Oriented Modeling constructs • Provide stereotypes to annotate the model elements that are affected by aspects (The Model Joinpoints). • Provide a reflection library (thisJoinPoint)

  26. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 An Aspect

  27. All method calls with 2 args Tracing with 2 params All send signal with 2 args All method executions with 2 params All state machine initialize with 2 params All receive signal with 2 params All state machine termination with 2 params Aspect Deployment: Apply tracing to 4 packages Motorola WEAVR A Profile for modeling Aspects in UML 2.0

  28. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 A Pointcut

  29. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 A Connector

  30. Motorola WEAVR A Profile for modeling Aspects in UML 2.0

  31. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 WEAVR Aspect-Oriented Modeling constructs:

  32. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 • An Aspect is a specialization of a Class. As such, it has all the properties of a regular class. It can define operations, attributes, ports, signals, timers, etc. Aspects can also contain two special types of Operations: Pointcuts and Connectors. • A Pointcut is an operation that defines a query over model State Machine Entities. A pointcut is defined with respect to an Expression. An expression is a pattern over Operation, Signals or Timer signatures. • A Connector is an operation that encapsulates the behavior that is injected at the locations in the model that match a pointcut expression. • The Binds dependency specifies a binding between Connectors and Pointcuts.

  33. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 New Joinpoint Model: State Machine Actions and Transitions Action Joinpoints: • Call Expression ActionJoinpoints (equivalent to call joinpoints) • Create Expression Action Joinpoints • Output Action Joinpoints • Timer Set Action Joinpoints Transition Joinpoints: • Start Transition Joinpoints (equivalent to execution joinpoints) • Initialization Transition Joinpoints • Termination Transition Joinpoints • Triggered Transition Joinpoints

  34. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 Action Joinpoints

  35. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 Transition Joinpoints

  36. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 New Pointcut Language: Actions and Transitions Action Pointcuts:

  37. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 Action Pointcuts: example

  38. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 New Pointcut Language: Actions and Transitions Transition Pointcuts:

  39. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 Transition Pointcuts: examples

  40. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 Action Pointcuts: example

  41. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 Aspect deployment entities

  42. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 Aspect deployment entities • Aspect deployment entities are use to define which model Packages or Classes are subject to Aspect weaving. • A Deployment Diagram specifies the relationship between Aspects and Model Packages and Classes, as well as the relationships between Aspects. • The Crosscuts dependency specifies which Packages or Classes are subject to weaving for a specific Aspect. • The Follows dependency defines the order in which Aspects are woven in the model, when those interact with the model at the same locations.

  43. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 Aspect deployment entities

  44. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 Aspect deployment entities

  45. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 Aspect deployment entities

  46. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 Aspect Visualization Stereotypes

  47. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 Aspect Visualization Stereotypes • The Show Joinpoints ( ) WEAVR operation allows the user to visualize the locations in the model where Aspects apply. • Annotations are inserted in the model to indicate which Pointcuts and Aspects interact with the model at these locations. • Joinpoints ( ) are Model Elements that match a Pointcut Expression. • The jpContext ( ) stereotype extends State Chart Diagrams that contains Joinpoints. • The Before and After stereotypes are used to delimit the entry point and the exits point of Transition Joinpoints.

  48. Motorola WEAVR A Profile for modeling Aspects in UML 2.0 ThisJoinPoint Reflective API

  49. Motorola WEAVR An Agent for visualizing Joinpoints and Analyze Joinpoint Effects Example: Ping Pong

  50. Motorola WEAVR An Agent for visualizing Joinpoints and Analyze Joinpoint Effects Example: Ping Pong

More Related