User Tools

Site Tools


tracing:ex3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tracing:ex3 [2008/10/06 17:12] – created bdefraintracing:ex3 [2021/02/05 13:55] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== Tracing: Specialized logging ======+[[tracing:intro|Intro]] 
 +[[tracing:ex1|Ex1]] 
 +[[tracing:ex2|Ex2]] 
 +[[tracing:ex3|Ex3]] 
 +====== ContextPoints in groups ====== 
 + 
 +===== Specialized tracing ===== 
 + 
 +**Task:** Pass the suite ''tests.PointGroupLog''
 + 
 +Write an aspect to log whenever a ''Point'' is added to a ''Group''. Note that this requires a dynamic ''instanceof'' test, because in principle any figure element can be added to a group. The log message should simply be: 
 + 
 +    adding Point 
 + 
 +<note tip> 
 +Use the ''args'' primitive pointcut. Besides exposing context objects, ''this'', ''target'' and ''args'' can also be used to include a dynamic type test in the pointcut. 
 +</note> 
 + 
 +With your aspect you should be able to pass the tests of suite ''tests.PointGroupLog''
 + 
 +===== Extension to invariant checking ===== 
 + 
 +**Task:** Pass the suite ''tests.PointGroupInvariant''
 + 
 +Add similar advice to ensure that a ''Point'' is never added to more than one ''Group''. If this invariant is violated, the advice should throw an ''IllegalStateException'' that uses the string representation of the first group as its message. 
 + 
 +Take a look a the implementation of the test case to see what is precisely expected. 
 + 
 +<note tip> 
 +Use an inter-type field declaration to associate a field of type ''Group'' with each ''Point'' object. Check and set this field from the advice. 
 +</note> 
 + 
 +---- 
 + 
 +After you have completed the exercise, remove your aspect from the build path; then return to the [[:start|Overview]].
  
tracing/ex3.1223305922.txt.gz · Last modified: 2008/10/06 17:12 by bdefrain