SDA SE Wiki

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

User Tools

Site Tools


Assignment 06: Aspect Oriented Programming

Release date: Monday, 25.11.13 - Due date: Sunday, 01.12.13, 23:59

Make sure that you installed the AspectJ Development Tools.

Task 31: Aspect Oriented Programming Concepts

11 = 7+4 points

a) Formulate in 1-3 sentences a description in your own words for:

  1. scattering
  2. tangling
  3. intertype declaration
  4. joinpoint ( no, it's not “joint point” ;-) )
  5. pointcut
  6. call pointcut
  7. advice

b) At the beginning of the lecture we enacted the possibilities of intercepting the communication between components (e.g. CORBA, Enterprise Java Beans, OSGi).

  • Describe how this offers a kind of Aspect Oriented Programming. (~ 2-3 sentences)
  • Describe the similarities and differences between the Joinpoint Model of this kind of AOP with AspectJ's Joinpoint Model. (~ 2-4 sentences)

Task 32: Removing Tangling

10 points

You can find the source code for this assignment in the project A06T32_UntanglingBanking. 'BankSession' in the folder 'tangled' contains the example for tangled code from the lecture. 'untangled' contains already a new untangled 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 (slides 22-25).


Task 33: Removing Scattering

8 points

Check out the project A06T33_UnscatteringSecurity. 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) As this is a bit tricky, you get 2 points just for getting the tests run.

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 34: Distribution as an Aspect

8 points
This task is not as tested as the previous tasks. If you run into trouble, don't hesitate to ask on the mailing list! If the compiler complains about potential exceptions you can just extend the throws clauses. A better design might be to wrap the exception in a RuntimeException.

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

The base code you find in A06T34_DistributedReservation 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 to the ReserverationHandler interface, see the AspectJ Quick Reference how this can be done (declare parents ..).
  • Introduce Serializable to other classes, where it is required.
  • 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.

Task 35: Understanding Dynamic Joinpoints Deeper (optional)

[2 + 6 points]

a) Read through the last slides of the AOP lecture to understand how the DisplayUpdating aspect can be optimized with the cflow and cflowbelow pointcuts. Explain the solution in 2-4 sentences.

b) For those of you who like to play around with some algebraic equations, we have some cute challenges here. Nevertheless, the goal of this task is not start an axiomatic theory of pointcuts, but practice thinking in dynamic joinpoints:

Are the following equations true? The == operator should be read as “has the same semantics as”.

  • Find a counterexample for each equation that is not true.
  • For the true equations give us a short argument.
01) cflow(cflow(ptc))   == cflow(ptc)

02) cflow(ptc1 || ptc2) == cflow(ptc1) || cflow(ptc2)
03) cflow(ptc1 && ptc2) == cflow(ptc1) && cflow(ptc2)

04) cflow(cflow(ptc1) || ptc2) == cflow(ptc1) || cflow(ptc2)
05) cflow(cflow(ptc1) && ptc2) == cflow(ptc1) && cflow(ptc2)

06) (cflow(ptc1) && !cflow(ptc2)) || (!cflow(ptc1) && cflow(ptc2))
                                  == 
    (cflow(ptc1) || cflow(ptc2))  && !(cflow(ptc1) && cflow(ptc2))

07) cflowbelow(cflow(ptc)) == cflow(ptc)
08) cflowbelow(cflow(ptc)) == cflowbelow(ptc)
09) cflow(cflowbelow(ptc)) == cflow(ptc)
10) cflow(cflowbelow(ptc)) == cflowbelow(ptc)

11) !cflow(!cflowbelow(ptc1)) == !cflow(ptc2) && (cflowbelow(ptc2) || ptc2)
  • One of the examples is rather supposed to be a joke, but is still true or maybe false. Another example has nothing to do with pointcuts but is nevertheless true. (0,5 points for spotting at least on of these.)
1)
Tips to get it running on a Mac from a former ATSC student: […] 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/2013/assignment_06.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2025