1

I want to track all my public method calls under a certain condition. But I want this tracking to hurt the whole system performance as little as possible.

I would need a way how to "turn on" a pointcut dynamically to be executed just for a specified thread and this turning on (and off) would have to be dynamically callable from my code.

I.e. if my Java code finds out that a certain thing happened it would turn on a pointcut for it's own thread. This pointcut would log all public method calls and after some time (or some number of interceptions) the pointcut would turn itself off.

Of course, I could call a code in the advice like "...getCurrentThread().equals(myMonitoringThread) && monitoringEnabled" but that would mean that the advice would be run for all public method of all threads and always execute this code which would certainly hurt the performance of the whole application.

What I would like to have is isolating the performance penatly just for the selected thread for the enabled time and leave the rest of the threads unaffected.

Does anybody know about a technique how to do it?

Thanks Tomas

1 Answers1

0

When you use aspects, your classes are affected : the bytecode is modified to be aspect compliant (or in the case of Spring, your calls are proxied with a dedicated aspect compliant class).

In the case of AspectJ it can be done during compilation, just after the compilation or at load-time (have a look here). Instrumented classes are affected the way your aspects are defined (intercept all public methods for example) and that means they can't really be de-affected at runtime (even if I'm quite sure that a crazy coder could invent a load/unload class mecanism to handle that but it would be insane ;).

So to answer your question, I think you can't fully plug/unplug your aspects at runtime in a simple way (if it's only possible !).

Julien
  • 2,544
  • 1
  • 20
  • 25