• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic