1 / 42

Features of AOP languages

Features of AOP languages. AOP languages have the following main elements: a join point model (JPM) wrt base PL a specification language for expressing sets of join points (JPS) a means of specifying behavior involving join points (BJP) encapsulated units combining JPS and BJP (CSB)

nicki
Télécharger la présentation

Features of AOP languages

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. Features of AOP languages • AOP languages have the following main elements: • a join point model (JPM) wrt base PL • a specification language for expressing sets of join points (JPS) • a means of specifying behavior involving join points (BJP) • encapsulated units combining JPS and BJP (CSB) • method of attachment of units to base program (AU)

  2. Comparing • AspectJ • DemeterJ • DJ • ATC • AspectC

  3. AspectJ JPM • principled points of execution • message sends (basically a method call), message receptions, method executions • field references (get and set) • exception throwing and handling • constructor execution • which context is available at each join point?

  4. AspectJ JPS • pointcut designators • primitive: calls(sig), receptions(sig), executions(sig), instanceof(type), within(type), cflow(pcd), getter(sig?), setter(sig?) • operators: &&, ||, ! • can name a pointcut and expose context • pointcut foo (V v):pcd (using v); • pointcut maybe abstract (declaration) and defined in a subaspect.

  5. AspectJ BJP • before, after, around: a pointcut. • can refer to thisJoinPoint • explain join point object: • instance of JoinPoint class. Interface: getSignature(), getActualParameters(),… • JoinPoint has eleven subclasses: CallJoinPoint, ReceptionJoinPoint, ExecutionJoinPoint, ExceptionJoinPoint, … • in around (instead of) can say: proceed()

  6. AspectJ CSB • an aspect contains a list of advice and point cut declarations and introductions and regular fields and methods.

  7. Explaining aspect instance • when you declare an aspect, you say either of eachJVM() or of eachobject(pcd) • logging: log stream put in aspect instance of each VM (one instance for whole program) • dft: mark field put it in aspect instance of each object (node object of the graph)

  8. AspectJ AU • ajc takes a list of files: aspects and classes and weaves them together.

  9. DemeterJ JPM • traversal method calls on Java object, constructor calls

  10. DemeterJ JPS • strategies • define family of traversal programs to be enhanced • approximation: function mapping object graphs to subgraphs • sentences • define family of Java objects: executions of constructor calls

  11. DemeterJ BJP • visitor classes • before *

  12. DemeterJ CSB • adaptive methods • void f() to S (V1, V2)

  13. DemeterJ AU • make new .beh file, add to .prj file, demeterj

  14. DJ JPM • object graph : nodes and edges • principled points: traversal of nodes or edges • fix a traversal algorithm

  15. DJ JPS • strategies • define family of traversal programs to be enhanced • approximation: function mapping object graphs to subgraphs (object graph slices)

  16. DJ BJP • visitor classes • before(A a), after(C c), cbefore_x(Object a, Object b), caround_x(Object a, Object b, Subtraverser st) • each method applies to a different part of the point cut (strategy)

  17. DJ CSB • aspectual methods void f(ClassGraph cg) { cg.traverse(this, “from A to S”, new Visitor() {…});}

  18. DJ AU • add methods to classes

  19. DJ: Second view: Doug

  20. DJ JPM • object graph slices: nodes and edges • fix a traversal algorithm

  21. DJ JPS • strategies • define family of traversal programs to be enhanced • approximation: function mapping object graphs to subgraphs (object graph slices) • in addition: visitor methods are pointcut designators • pointcut designators are encoded in signatures of visitor methods

  22. DJ BJP • visitor classes • each visitor method is advice on the point cut specified by the method signature

  23. DJ CSB • a visitor class is a package of advice • when you use a visitor in a traversal of an ogs (in traverse) then each pointcut is intersected with the traversal pointcut, namely cflow(traverse). (can also use within)

  24. DJ AU • to attach an aspect you call traverse with an aspect (visitor). • traverse expression attaches the aspect to an object graph slice.

  25. AspectC JPM • function calls, variable references • data available: args to function calls

  26. AspectC JPS • point cut designators • call (foo( c )): all calls of function foo with one argument • cflow( any point cut designator): “whatever comes afterwards on the stack” • varref(name) • combine with && , || and !

  27. AspectC BJP • before, after, around

  28. AspectC CSB • are hardwired together: when advice is given, you need to give point cut

  29. AspectC AU • concatenated to the source

  30. ATC JPMAspects in Tiny CLOS • generic function receptions, method executions • use MOP to implement aspects • what data is exported: see join point object

  31. ATC JPS ! • point cut designators • predicate on aspect instance and join point object • explain join point object: • instance of <join-point> class. Interface: slots: generic (generic function being called), args (actual parameters), stack (stack of join points in current control flow) • <join-point> has two subclasses: <reception-join-point> and <execution-join-point> • <execution-join-point> has additional slot: method (being executed) • (all the traversal methods in the cflow of the first traversal call)

  32. ATC BJP • before, after, around: take aspect instance and join point object as argument. • around has third arg: continuation • generic function ...

  33. ATC CSB • advice has a pointcut generic function (like an abstract pointcut in AspectJ). Methods of generic function are specified separately. • an aspect contains a list of advice (no point cut declaration) • an aspect is an instance of <aspect>

  34. Explaining aspect instance • class <aspect> has two subclasses: <aspect-of-each-vm> <aspect-of-each-object > • logging: log stream put in aspect instance of each VM (one instance for whole program) • dft: mark field put it in aspect instance of each object (node object of the graph)

  35. ATC AU ! • <aspectizable> mixin: has slot aspects: holds list of attached aspects • <aspectizable-generic> is a subclass of both <generic> and <aspectizable> (<generic> is the class of all generic functions) • add-aspect! , remove-aspect! • all generic functions in base program are aspectizable (non-obliviousness ok)

  36. Aspectual Collaborations JPM • principled points of execution • abstract join points that are mapped by the adapter to concrete ones • execution of methods modified by collaboration • enhance the class graph: open classes: add more members to existing classes • which context is available at each join point?

  37. Aspectual Collaborations JPS • sets of join points: collaboration + adapter (in the adapters we express the cross cutting) • collaboration roles only: have the flavor of an abstract pointcut.

  38. Aspectual Collaborations BJP • before, after, around: for methods • can refer to actual parameters • in replace (around (instead of)) can say: expected()

  39. Aspectual Collaborations CSB • collaborations and adapters

  40. Aspectual Collaborations AU • ac-compiler (non existent) takes a list of files: classes and collaborations and adapters and weaves them together.

  41. Using AspectJ to implement collaborations/adapters • AspectJ can only express the adapted collaborations • AspectJ supports interfaces with full methods and multiple inheritance

  42. Goal • Input: classes, collaborations, adapters • Output: AspectJ code

More Related