SDA SE Wiki

Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools


Assignment 7: Aspect Oriented Programming

Due at Thursday, December 17th, 11:00 am (before the lecture starts)
Make sure that you installed the AspectJ Development Tools.

Task 17: Removing Tangling

5 points

You can find the sourcecode for this assignment in the project A07T17_UntanglingBanking. 'BankSession' in the folder 'tangled' contains the example for tangled code from the lecture. 'untangled' contains already a new untangeld version with aspects. Sadly the aspects still need to be implemented. Your task is to restore the functionality found in the tangled example code. Don't change anything except for the aspects. Make sure the test runs.

Implement the aspects ContractChecking, Security Logging and Transactionality. The aspect ContractChecking should contain all functionality that checks the input arguments, the supposed content of the aspects Security, Logging and Transactionality should be obvious.

If you are unsure about what code in the tangled application matches what concern take a look at the lecture slides (slide 20,21).

Task 18: Removing Scattering

3 points

Check out the project A07T18_RefactoringExercise. Your task is to de-scatter another banking example. Extract the permission checking (the calls to AccessController.checkPermission(..)) into an aspect. Don’t forget to run the JUnit-tests after each step.

Before you can run the tests you will have to adapt the banking.policy file as described in notes.jpage.1)

It should be possible to solve this just ad-hoc. If someone wants to learn a systematic way of doing this refactoring, she might want to read slide 15 and following of the refactoring class of the AOSD lecture, or the original article by Ramnivas Laddad on which the lecture is based.

Task 19: Distribution as an Aspect

4 points

In this task you will introduce RMI-based distribution to the banking example. If you are completely new to RMI have at look at a RMI tutorial first.

The base code is not distributed, yet. We already anticipated that a distributed object must always be accessed via an interface and all methods in the interface must throw the checked exception RemoteException, see hotel.control.ReservationHandler.

Your task is to complete the aspect hotel.control.Distribution which should:

  • Introduce Remote and Serializable to the ReserverationHandler interface, see the AspectJ Quick Reference how this can be done (declare parents ..).
  • Uncomment the RMI server code in the hotel.control.StartTestServer class, which is responsible for registering a remote reservation object.2)
  • Replace every access to the ReserverationHandler with a remote object. Hint: You can look up RMI object directly from the Registry, e.g.
Registry registry = LocateRegistry.getRegistry();
return (ReservationHandler) registry.lookup("<registered name>");
  • Start the server3) and run the test case.
1)
Tips to get it running on a Mac from Jonathan Simon: […] I am on a Mac and it was not a trivial task… The assignment seemed to be to get the test running, not to factor out an aspect (that was quick) ;) […]
  1. The path settings need to start with “file:/” and end with “/-”, e.g. “file:/Applications/eclipse-modeling/-” for my Eclipse location
  2. For running, I had to click “Run as > Run Configurations…”, then in the “Arguments” tab, in the “VM arguments field” replace the “\\” by “/” for the location of the policy file
I suppose this is equal for Linux.
2)
If you get error markers after this step. Close the editor and reopen the file with the AspectJ editor.
3)
To stop the server again, switch to the console for this process and press the red stop button.
teaching/lectures/atsc/2009/assignment_7.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2024