COM 3362 Aspect-Oriented Software Development Karl Lieberherr Winter 2002 Homework 7 Integrating Demeter into AspectJ using Aspect-Oriented Programming prepared with John Sung Due Feb 26, 2002 So far we have integrated traversals into AspectJ by translating traversal specifications into introductions. We can program the visitors using AspectJ syntax but this leads to verbose code. Therefore we would like to generate the pointcuts and advice from the visitor notation. The best way to add visitors to AspectJ without modifying the AspectJ tool is to add a visitor declaration language to the T language we introduced earlier. We want to do this with minimal extension to AspectJ and by 100% Java using the Java interface language. aspect Traversals { declare traversal t1 : "from Basket to *"; declare traversal t2 : "from Basket to Weight"; } becomes: aspect Traversals { declare visitors : Visitor1Interface, Visitor2Interface; declare traversal t1(Visitor1Interface) : "from Basket to *"; declare traversal t2(Visitor1Interface) : "from Basket to Weight"; } This means that in one of the Java files there must be an interface like: interface Visitor1Interface { void before(A a); void after(B host); void after(C host); void start(); void finish(); } This produces a traversal method void t2(Visitor1Interface v1) for Basket-objects. AspectJ is used as follows: ajc *.java // first compilation java Main > traversals.java ... // first run (stopped prematurely) ajc *.java // second compilation java Main ... //second run Information about the interfaces can be collected in the first run using Java reflection. http://java.sun.com/docs/books/tutorial/reflect/class/isInterface.html Edge methods: ============= Reuse the design from assignment 4, part 3c and also translate edge methods to AspectJ syntax. Around methods: =============== Also add around methods for both nodes and edges to your tool. They have an additional argument of type SubTraversal with a method apply() and a method apply(String s). apply continues the traversal and apply("edgeName") continues the traversal on edge "edgeName". See: /proj/adaptive2/course/com1205/w02/project/ for more information