Title: Declarative Techniques for Improving Aspect Orthogonality
1Declarative Techniques for Improving Aspect
Orthogonality
2Feature interaction
- traversal(t) should go across many pointcuts
- traversal(t) traversal(t1) subtraversal
- desired structure
- t(A a, B b, ) traversal(t1)
- target(A a)
- traversal(t2) this(a) target(b)
- crossing(x,B b)
3why we need nested traversals t1(A a, B b, C, R
r, S s, int count) traversal (tfrom aA via
bB via -gt ,x, to cC) target(a)
print(a) target(b) print(b) target(
c) count crossing (x) this(r)
target(s) aspect A int c before
t1( when pointcuts contain advice we have to
transport fewer variables.
4why we need nested traversals t1(A a, B b, C, R
r, S s, int count) traversal (tfrom aA via
bB via -gt ,x, to cC) target(a) advice
a1() target(b) advice a2() print(b)
target( c) count crossing (x)
this(r) target(s) aspect A int c
before t1( when pointcuts contain advice we
have to transport fewer variables.
5why we need nested traversals traversal tfrom
aA via bB via -gt ,x, to cC before
traversal(t) target(A a1) before
traversal(t) target(B b1) print(b1)
target( c) count crossing (x)
this(r) target(s) aspect A int c
before t1( when pointcuts contain advice we
have to transport fewer variables.
6- traversal(t) get(Signature) all field
accesses during traversal - traversal(t) handler(TypePattern)
- traversal(t) this(TypePattern) when traversal
- visiting(TypePattern)
7more integration
- traversal(t) crossing(xyz) this(a)
target(b) args(v1, tS) - explanation traversal t through edge xyz with
source a and target b. The visitor is v1 and the
token set is tS. tS allows us to query the state
of the traversal we can ask which strategy graph
edges are currently active.
8- traversal(t) cflow(call( f(..)) all join
points - join(traversal(t1), traversal(t2))
- traversal(t1) traversal(t2)
- traversal(t1) !traversal(t2)
- traversal(from A to B) !traversal( from A
via X to B) from A bypassing X to B
9cflow
- is traversal the only pcd where we want nesting
with advice?
10- difference between visiting(a) and this(a) and
target(a) - traversal(t) target(a) visiting(a)
- this(a) where traversal was before getting to
a-object
11AOP1 ClassGraph List(Traversal)
List(PointCut) List(Advice). PointCut Simple
Compound. Simple CallJoinPoint.
12dynamic call graph
aCompany.t()
aCompany.t_domesticDivisions()
1
1
2
2
aCompany.domesticDivisions
2
aCompany.t_foreignDivisions()
1
a_d_DivisionList.t()
a_f_DivisionList.t()
aCompany.foreignDivisions
13dynamic call graph
a1Division.t_departments ()
a_d_DivisionList.t()
1
2
2
1
a1Division.departments
a1Division.t ()
a2Division.t ()
aDepartmentList.t()
etc.
14From Adaptive to Aspect-Oriented Programming
- Object-graphs are turned into dynamic call graphs
by traversal methods produced from the class
graph and a traversal specification. - As we go through dynamic call graph, we want to
collect information from arguments and return
values of method calls. - Exploit regularities in call graphs.
15Motivation
- Declarative techniques used in existing AOP
systems - Look at a family of declarative techniques use
one uniform syntax and three different semantics.
16Flow Expressions
- D A,B join(D1,D2) merge(D1,D2)
- We can use them in three different graphs
relevant to programming - call trees subset of nodes
- class graphs subset of nodes
- object trees subgraph
17Flow Expressions and AOP
- They are a basic cross-cutting construct for
defining subgraphs. - merge(join(A,X,X,C), join(A,Y,Y,C))
defines a subgraph of a larger graph whose ad-hoc
description cuts across many nodes or edges. - succinct encapsulations of subgraphs related to
some aspect.
X
A
C
Y
18Flow expressions
- are abstractions of some aspect whose ad-hoc
description would cut across many nodes or edges
of a graph. - define sets of join points based on connectivity
in graph. - offer pointcut designator reduction (high-level
pointcut designator) free programmer from
details of some graph representing some aspect.
19Definitions for Flow Expressions
- D A,B join(D1,D2) merge(D1,D2)
- Source(A,B) A
- Target(A,B) B
- Source(join(D1,D2) )Source(D1)
- Target(join(D1,D2) )Target(D2)
- Source(merge(D1,D2) )Source(D1)
- Target(merge(D1,D2) )Target(D1)
20Well-formed Flow Expressions
- D A,B join(D1,D2) merge(D1,D2)
- WF(A,B) true // well-formed
- WF(join(D1,D2) )WF(D1) WF(D2) Target(D1)
Source(D2) - WF(merge(D1,D2) ) WF(D1) WF(D2)
Source(D1)Source(D2) Target(D1)Target(D2)
21Dynamic call tree
- nodes are operation calls labeled by operation
name and arguments - edges a operation calls another operation
- nodes join points
22context-passing aspects
abstract aspect CapabilityChecking pointcut
invocations(Caller c) this(c) call(void
Service.doService(String)) pointcut
workPoints(Worker w) target(w) call(void
Worker.doTask(Task)) pointcut
perCallerWork(Caller c, Worker w)
cflow(invocations(c)) workPoints(w)
before (Caller c, Worker w) perCallerWork(c, w)
w.checkCapabilities(c)
23Interpretation of traversal strategies
- D A,B join(D1,D2) merge(D1,D2)
- A and B are pointcut designators.
- A,B the set of B-nodes reachable from A-nodes.
- join(D1,D2) the set of Target(D2)-nodes
reachable from Source(D1)-nodes following D1 and
then following D2.
24Interpretation of traversal strategies
- merge(D1,D2) the union of the set of
Target(D1)-nodes reachable from Source(D1)-nodes
following D1 and the set of Target(D2)-nodes
reachable from Source(D2)-nodes following D2.
25Translation Rules
- t(D1)
- flow(A) B
- t(D1) t(D2)
- flow(t(D1)) t(D2)
- D1
- from A to B
- merge(D1,D2)
- join(D1,D2)
26Class graph
flow expressions are called traversal strategies
Demeter/C DJ
Type patterns in AspectJ
- D
- A,B
- join(D1,D2)
- merge(D1,D2)
- PathSet(D)
- Paths(A,B)
- PathSet(D1).PathSet(D2)
- PathSet(D1) PathSet(D2)
we are only interested in the set of
nodes touched by the path sets -gt subgraph of
class graph
27Object tree
flow expressions are called traversal strategies
Demeter/C DemeterJ DJ
generate traversals in AspectJ
- subgraph of O
- subgraph of O consisting of all paths from an
A-node to a B-node, including prematurely
terminated paths.
28Object tree
- subgraph of O
- subgraph of O consisting of all paths following
D1 and those reaching Target(D1) concatenated
with all paths following D2.
29Object tree
- subgraph of O
- subgraph of O consisting of all paths following
D1 or following D2.
30Purposes of strategies
- DJ
- Traversal
- strategy graph
- class graph
- object graph
- Purposes
- select og with sg
- extract node labels
- select cg with sg
- AspectJ
- General computation
- strategy call graph
- static call graph
- dynamic call graph
- Purposes
- select dcg with sycg
- extract node labels
- select scg with sycg
31Purposes of strategies
- DJ method edges
- Traversal
- strategy graph
- class graph
- object graph
- argument map
- Purposes
- select dcg with sg am
- extract node labels
32Use single argument methods only?
- can always package multiple arguments into an
object.
33Correspondences
- t(D1)
- flow(A) B
- flow(A)
- flow(flow(A) B) C
- flow(flow(flow(A) B) C) E
- (flow(flow(A) B1) C) (flow(flow(A)
B2) C) - t(D1) t(D2)
- flow(t(D1)) t(D2)
- flow(flow(A) B) (flow(B) C)
- flow(flow(A) B) C
- D1
- from A to B
- from A to
- from A via B to C
- from A via B via C to E
- merge(from A via B1 to C,
from A via B2 to C) - merge(D1,D2)
- join(D1,D2)
- join (from A to B, from B to C)
subset(flow(B)) flow(B) subset(flow(B))