User Tools

Site Tools


caching:ex4

This is an old revision of the document!


Caching: Invalidate (part II)

Task: Pass tests.Invalidation2a and pass tests.Invalidation2b.

Of course, the previous aspect didn't really solve the problem. What if a Point that is part of a Group moves? Whenever either of the fields of a Point are set it should invalidate the caches of all enclosing groups.

Store the enclosing Group as a newly introduced field of a FigureElement (intercept the add() method of Group to populate this field). When the FigureElement moves, the cache of its enclosing group should be invalidated (if there is an enclosing group and if there is a cache value for this group).
If you use aspectOf, but no corresponding aspect instance can be found, the AspectJ runtime will throw the NoAspectBoundException. (Catching this exception is a way to test whether there is an aspect instance available.)

A correct implementation should at least pass the tests of suite tests.Invalidation2a.

However, check if you really did it correctly by also running the suite tests.Invalidation2b. If you pass, congratulations! Otherwise, you have fallen prey to our cruel trap: Remember that whenever a point moves it should invalidate the caches of all enclosing groups (recursively).


When done, remove your aspects from the build path and return to the Overview.

caching/ex4.1223382209.txt.gz · Last modified: 2008/10/07 14:23 by bdefrain