Aspect-Oriented Software Development (Advanced Object-Oriented Systems) COM 3362 Fall 2002 Homework 2 ========== Note: /home/lieber/.www/com3362/w02/ = http://www.ccs.neu.edu/home/lieber/com3362/w02/ Due date: Jan. 22. AspectJ can be used to implement the growth phases of a project so that a phase i+1 does not require changes to phase i. The new phase can often be described only as an addition. In this homework we first deal with the Visitor design pattern using such an additive approach and in part 2 we express error handling as an additive aspect. PART 1: ======= The starting point is the Java program in: http://www.ccs.neu.edu/home/lieber/com3362/w02/hw/2/graph/gen/ which contains a skeleton of a Java application for counting the number of inheritance edges in a simplified UML class diagram. You compile this skeleton with ajc *.java and you run the program with java Main < ../class-graph.input Your task is to make this skeleton complete so that it correctly counts the number of inheritance relations. You are not allowed to modify my program. Instead you write an aspect called Count that does the counting. Turn in your aspect and the answer it produces. Hint: The program I give you already does the right traversal with methods allInh_Cd_graph_trv*. All your aspect needs to do is to initialize and update a counter at the appropriate times during the traversal. PART 2: ======= Consider the simple library application in http://www.ccs.neu.edu/home/lieber/com3362/w02/hw/2/library It deals with checking out books from a library. But the application has no facilities for error handling. Your task is, without changing the given application, to implement the following error handling: Book name incorrect or copy is unavailable! UserId incorrect! Turn in your aspect that prints the above two error messages at the appropriate times. Acknowledgements: PART 1 - PART 2 tested by Pengcheng Wu. Note: In order to run the library program, you need the appropriate *.jar file in your class path: /proj/adaptive3/wupc/html/alpha.jar