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