1 / 25

A Disciplined Approach to Aspect Composition

A Disciplined Approach to Aspect Composition. Roberto Lopez-Herrejon Don Batory Christian Lengauer. Presented By: Donny Hallman. Agenda. Terms Introduction to AspectJ Incremental Development Algebraic Model Functional Model Proposed Solution Conclusion. Terms*.

knoton
Télécharger la présentation

A Disciplined Approach to Aspect Composition

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. A Disciplined Approach to Aspect Composition Roberto Lopez-Herrejon Don Batory Christian Lengauer Presented By: Donny Hallman

  2. Agenda • Terms • Introduction to AspectJ • Incremental Development • Algebraic Model • Functional Model • Proposed Solution • Conclusion

  3. Terms* • Base code – non-aspect part of a program • Join points – points in the structure or execution of the program • Pointcut – a logical description of a set of join points • Advice – additional behavior • Aspect – term for an advice adding behavior to a pointcut. Introduction – function that adds a data member or method to a program. * From wikipedia (http://en.wikipedia.org/wiki/Aspect-oriented_programming)

  4. Introduction to AspectJ • Static Crosscuts BASE CODE class Point { int x; void setX(int v) { x = v; } } ASPECT CODE aspect TwoD { int Point.y; void setY(int v) { y = v; } } + NEW COMPILED CODE class Point { int x; void setX(int v) { x = v; } int y; void setY(int v) { y = v; } }

  5. Introduction to AspectJ (cont’d) • Dynamic Crosscuts ASPECT CODE aspect Logging { after() : execution( * Point.set(..)) { System.out.println(“Logged”); } } BASE CODE class Point { int x; void setX(int v) { x = v; } } + NEW COMPILED CODE class Point { int x; void setX(int v) { x = v; System.out.println(“Logged”); } }

  6. Advice Precedence • Advice Precedence (two options) EXPLICITLY DECLARED declare precedence: Aspect3, Aspect2, Aspect1 • COMPILER DETERMINED • If there are two pieces of advice for the same aspect: • If both are after advice, then the advice that appears later, has precendence over the one that appears earlier. • Other cases, the first has precedence

  7. Advice Precedence Circular problem fixed with declaration

  8. Incremental Development

  9. Incremental Development (cont’d)

  10. Incremental Development Example (cont’d) DESIRED RESULT ACTUAL RESULT

  11. Incremental Development (cont’d) Possible Solution: *Though a solution, this removes ability to reuse the aspect.

  12. Algebraic Model of Aspects ADVICE (AS SHOWN EARLIER) PURE ADVICE (AS USED IN MODEL) CONCEPTIAL VIEW OF ASPECT

  13. Introduction Sum Point1 = TwoD(Point0) = TwoD + Point0 = {setY + y} + {setX + x} = setY + y + setX + x = {setY, y, setX, x} + differs from AspectJ introduction in that it does not allow member overriding. Also, this model allows new classes and interfaces to a program.

  14. Weaving • Identity – where id is a null advice, program P = id(P). • Associativity – right associative • Distributivity – Weaving distributes introduction sum, where X, Y, and Z are arbitrary program fragments:

  15. Advice Sum Advice sum is characterized by “•”. • also models advice precedence (a3•a1 means apply a1 first then a3) • Identity – if id is a null and “a” a pure advice • Commutativity – The order in which advice is applied matters • Associativity – • is associative because function composition is associative.

  16. Modeling Aspects as Pairs • The first entry is the advice part, and the second is the introduction part, such that for the logging example:

  17. Modeling Aspects as Pairs (cont’d) • The Circular Example:

  18. Aspect Composition

  19. Aspect Composition (cont’d) • Illustration of the problem: • To apply aspect A2, the programmer is required to know how an advice from a previous step (a1) affects the introduction of the current step. The problem gets worse when more aspects are added.

  20. Functional Model • Compose aspects with functional composition and model as such. • The offending advice from before disappears. • Generalizes to any number of compositions • The weavings that make step-wise development difficult are never generated

  21. Functional Model (cont’d) • The functional model causes the aspects to be expressed in terms of bounded quantification. • The Point example before could be bounded in four ways:

  22. Recommendation • Remove precedence rules and apply advice in the order which it is listed in an aspect file • Precendence should be declared for ALL aspect files. The compile could raise errors if not the case.

  23. Conclusions • Problems occur in AspectJ with step-wise development when pointcuts are not bounded to classes, methods, and variables at a specific stage of program development. • Use of Algebra exposes a source of current problems and reveals a solution. • Investigating other AspectJ capabilities.

  24. Critique of Paper • Important to formalize and analyze AspectJ capabilities in with Algebra. • Model seems to expose problems, and solutions seem reasonable. • Much more research and actual implementation need to be done to show the true impact on performance.

  25. Questions?

More Related