COMP6255-无代写
时间:2023-05-09
COMP6255 - Coursework Two
Module: Advanced Programming Language Concepts Lecturer: Julian
Rathke
Assignment: Object logging using AspectJ Weighting: 20%
Deadline: 16/5/2023 Feedback: 6/6/2023 Effort: 15 hours
Instructions
The overall goal of the coursework is to use AspectJ to implement an object tracing aspect that
protocols all changes to objects of certain classes in log files.
Part 1: Logger
Write an aspect called Logger that traces all objects that are created whose class type has been tagged with
the Java annotation @logging. AspectJ provides pointcut descriptors to identify such classes: see the quick
reference guide at http://www.eclipse.org/aspectj/doc/next/quick5.pdf for details. For each such object
created you should create an entry in a Comma Separated Value Log File that lists
• a unique object identifier of the object that is created
• the time at which the constructor method is called, and
• the location in the Java source code at which the constructor method is called.
• the arguments to the call to new (for object creations)
In the argument list, your program should use a text representation for the values of primitive Java data types.
For values of reference type whose classes are annotated with @logging, you should use your own object
identifiers to represent objects. For any other types, simply use the default toString() method.
You should create a separate CSV log file for each class annotated with @logging. Each of these files will
contain a log of objects created of that class types. It is okay to create empty log files for those classes that
have no objects created.
Part 2: Object comparisons
Use AspectJ to add a public method boolean olderThan(Object x) to all objects that are instances of a
class annotated with @logging. This method returns true if the argument object is also an instance of a
class annotated with @logging and the receiver object was created before the method’s argument object.
Your implementation must ensure that y.olderThan(x) returns true if and only if x.olderThan(y)
returns false whenever x and y are different objects.
Submission
Please submit well documented AspectJ source code – do not submit any Java source files. We will test your
aspects on our own class files.
Please submit using the hand-in system (http://handin.ecs.soton.ac.uk) by 4pm on the due date.
Relevant Learning Outcomes
D1. Write code to incorporate advanced programming techniques
Marking Scheme
Criterion Description Outcomes Total
Part 1 AspectJ code for basic object creation logging D1 12 marks
Part 2 AspectJ code to generate the olderThan method D1 8 marks
Late submissions will be penalised at 5% per working day. No work can be accepted after feedback has been
given. Please note the University regulations regarding academic integrity.