Discussion with Gregor Kiczales at UBC Ontology of
Discussion with Gregor Kiczales at UBC • Ontology of AOP • Ontology is the study of what there is, an inventory of what exists. An ontological commitment is a commitment to an existence claim for certain entities. • Slides 2 - 5 and the last one are Gregor’s An ontology is, in simple terms, a collection of concepts with relations among them plus constraints on the relations. AO Mechanisms in Demeter 1
basis of crosscutting • a join point model (JPM) has 3 critical elements – what are the join points • in Aspect. J – points in runtime call graps members – means of identifying join points • in Aspect. J – signatures (plus …) – means of specifying semantics at join points • in Aspect. J – advice – define members AO Mechanisms in Demeter 2
basis of crosscutting • a join point model (JPM) has 3 critical elements – what are the join points • in Aspect. J – points in runtime call graph – class members dynamic JPM static JPM – means of identifying join points • in Aspect. J – pointcuts – member signatures (plus …) – means of specifying semantics at join points • in Aspect. J – advice – define members AO Mechanisms in Demeter 3
range of AOP languages JPM join points Aspect. J dynamic JPM points in execution call, get, set… static JPM class members Composition Filters message sends & receptions Hyper/J members Demeter traversals when traversal reaches object or edge AO Mechanisms in Demeter means of … join points identifying specifying semantics at signatures advice w/ wildcards & other properties of JPs signatures add members signature & property based object queries signatures class & edge names 4 wrappers declarative (filters) imperative (advice) add, compose (and remove) members define visit method
range of AOP languages JPM join points Aspect. J dynamic JPM points in execution call, get, set… static JPM means of … join points identifying specifying semantics at signatures advice w/ wildcards & other properties of JPs signatures add members class members Composition Filters message sends & receptions Hyper/J members Demeter traversals types signature & property based object queries signatures succinct traversal specs wrappers declarative (filters) imperative (advice) add, compose (and remove) members generate traversals See next slide for changes to Demeter AO Mechanisms in Demeter 5
range of AOP languages JPM join points Aspect. J dynamic JPM points in execution call, get, set… means of … join points identifying specifying semantics at signatures w/ wildcards & other properties of JPs signatures advice visitor method signatures visitor method bodies static JPM 1 class members traversal spec. s class graph g s + g (result = traversal implementation) static JPM 2 static JPM 3 class members class names class graph add members class graph with tokens=grammar (result = parsing and printing implementation) static JPM Demeter. J, Demeter/C++ dynamic JPM AO Mechanisms in Demeter class members when traversal reaches object or edge 6 add members
range of AOP languages JPM join points Aspect. J dynamic JPM points in execution call, get, set… static JPM DJ dynamic JPM 1 dynamic JPM 2 dynamic JPM 3 AO Mechanisms in Demeter means of … join points identifying specifying semantics at signatures w/ wildcards & other properties of JPs signatures advice when traversal reaches object or edge (method traverse) visitor method signatures visitor method bodies when traversal reaches object (methods fetch, gather, as. List) source and targets of traversal method name (fetch, gather, as. List) trav. spec. s class graph g object graph o s+g+o(result = traversal implementation = edges to traverse at nodes in object graph) class members nodes in object graphs 7 add members
Composing join point models • Traversal Spec JPM: In Demeter we use traversal specifications and the class graph to define a traversal implementation (either static or dynamic) • Visitor JPM: The result of Traversal Spec. JPM is used to define a second JPM: – The traversal implementation defines nodes and edge visits. – Visitor signatures define the nodes and edges where additional advice is needed: they are the means of identifying join points. – The means of specifying semantics at join points are the visitor bodies. AO Mechanisms in Demeter 8
DJ: dynamic JPM 3 • The join points are nodes in object graphs. They are not dynamic call graph join points nor class members! • The means of identifying the join points for a given object graph o are a strategy s and the class graph g. o must conform to g. • The means of specifying the semantics at the join points are again s and g. See paper with Mitch Wand for the formal details behind this JPM. AO Mechanisms in Demeter 9
Demeter. J: static JPM 1 • The means of identifying the join points and of specifying the semantics at the join points are the same. • The reason is that s+g both – select the classes that will get traversal semantics – determine the details of the traversal semantics AO Mechanisms in Demeter 10
Demeter. J: static JPM 3 • The means of identifying the join points (class members) is done by the class graph. • When we add tokens to the class graph we get a grammar that contains instructions for parsing and printing behavior. • A grammar is an aspect (external representation aspect): the adhoc implementation cuts across all classes. AO Mechanisms in Demeter 11
AO design in UML • Composition Patterns [Clarke, Walker] • foo – static JPM (~ Hyper/J) – binds pattern to base code – dynamic JPM (~ Aspect. J) – what happens in pattern • UML class & interaction diagrams • baralready crosscut – by-class vs. by-interaction organizations AO Mechanisms in Demeter 12
Masuhara/Kiczales Modeling Framework for AO Mechanisms • • • A and B: languages X: result domain of weaving process X[JP]: join points in X A[ID], B[ID]: identify join points in X A[Eff], B[Eff]: effecting semantics at jps META: parameterize weaving process AO Mechanisms in Demeter 13
Masuhara/Kiczales Modeling Framework for AO Mechanisms • • • X X[JP] A A[ID] A[Eff] B B[ID] B[Eff] META AO Mechanisms in Demeter 14
Demeter static JPM 1: special case of Open Classes • X – Combined program • Adds traversal methods X[JP] to a set of classes – c declarations • A – c declarations including the class graph • A[ID] – Method signatures • • A[Eff] B – Traversal specifications • B[ID] – c names • • B[Eff] META – Traversal semantics: rules for translating traversal specifications to methods AO Mechanisms in Demeter 15
Demeter static JPM 2: Open Classes See paper. AO Mechanisms in Demeter 16
Demeter static JPM 3: special case of Open Classes • X – Combined program • Adds parsing methods X[JP] to a set of classes – c declarations • A – c declarations including the class graph • A[ID] – Method signatures • • A[Eff] B – Class dictionary (class graph enhanced with tokens defining the syntax addition) • B[ID] – c names • • B[Eff] META – rules for translating class dictionary to parsing methods AO Mechanisms in Demeter 17
Demeter dynamic JPM 1: special case of Pointcuts and Advice • X – Traversal execution • Adds advice to traversal methods X[JP] – Arrival at each object and has-a edge • A – Traversal methods • A[ID] – Method signatures • A[Eff] – Execute traversal method body • B – Visitor method declarations (serves as advice) • B[ID] – Visitor method signatures (serves as pointcut) • B[Eff] – Execute visitor method bodies • META – none AO Mechanisms in Demeter 18
Demeter dynamic JPM 2: special case of TRAV For methods fetch, gather and as. List: special advice AO Mechanisms in Demeter 19
Demeter dynamic JPM 3 • X – Object graphs • X[JP] – Nodes in object graphs • A – Class graph • A[ID] – Class names • • A[Eff] B – Traversal specification • B[ID] – Class names • B[Eff] – Edges to traverse at node in object graph • META – Rules for traversal order: depth-first, breadth-first, left-to-right, etc. AO Mechanisms in Demeter 20
Demeter dynamic JPM 4: DJ with Functional Visitor • X – Traversal execution with runtime control (Subtraversal. apply(. . )) • X[JP] – Arrival at each object (Functional Visitor only available to nodes) • A – Regular Java Program (class/fields declarations) • A[ID] Mixes two models together – Class/fields signatures • A[Eff] – Provide reachability (my understanding is to construct object graph conforming to the class graph) • B – Traversal specification and visitor method declarations (including the default one: combine(. . )) • B[ID] – Visitor method signatures (or the built-in semantics, for the combine(. . )) • B[Eff] – Execute the visitor methods and compute and combine the values and provide the runtime control over the traversal(subset of the traversal graph computed from the traversal specification) • META
Demeter dynamic JPM 4: DJ with Functional Visitor • X – Traversal execution with runtime control (Subtraversal. apply(. . )) • X[JP] – Arrival at each object (Functional Visitor only available to nodes) • A – Regular Java Program defining traversals (class/fields declarations) • A[ID] – Method signatures • A[Eff] Taken apart – Execute traversal method body • B – Visitor method declarations (including the default method: combine(. . )) • B[ID] – Visitor method signatures (or the built-in semantics, for the combine(. . )) • B[Eff] – Execute the visitor methods and compute and combine the values and provide the runtime control over the traversal • META
Conclusions • The Modelling Framework by Masuhara/Kiczales nicely captures the different AO mechanisms worked on by the Demeter team. AO Mechanisms in Demeter 23
- Slides: 23