• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

AOP Challenge: can it do this ?

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's revisit the logging aspect. I need to add logging information
between two statements inside a method.
e.g.

I want to log the value of i after statement 4 and also after statement 5. Can AOP (e.g. AspectJ) do this ?
Thanks
Gavin
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Based on the quick reference, I doubt that's possible. On the other hand, the example you mentioned is not really cross-cutting, is it?
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After line 5 is easy. Just log the return from filter1().
After line 4 is hard only because i is not a true object. If i was an Integer object, or if you incremented i with its own method.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm finally starting to realize the power of the pointcut constructs...
 
Author
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gavin,
AspectJ does not expose join point corresponding to local variables inside a method (had "i" been a instance or class variable, you would be able to advice modifications to it).
As Michael points out, you could log the return values of calls to filter1() and filter2(). I would, however, suggest not using AspectJ for such purpose. Such logging isn�t really a crosscutting concern and therefore AOP won�t be the right tool for this job.
-Ramnivas
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic