kriegaex (1) [Avatar] Offline
Dear author,

in chapter 6.2.6 (Accessing aspect instances) you mention, that to get an instance of a percflow aspect I should use ClassName.aspectOf(). So far, so good. But under which circumstances or in which context can I get the instance? Do I need to be within that very control flow of which I want to get the aspect? If I am not, like in your example with a performance monitor collecting data from another thread, am I right to assume that there is basically no way of getting the aspect instance of interest? Or at least not the way you mentioned? Because I guess that using a static class method can only work for singleton aspects when calling it from outside the control flow of a cflow-bound aspect.

Maybe you can elaborate a bit more on this issue and maybe clarify it in the next edition of your book. Thanks.
ramnivas (171) [Avatar] Offline
Re: Unclear explanation: aspectOf for percflow[below]
Yes, you need to be in the control-flow. Under the hood, there is a thread local that is in effect at the entrance of the flow and is cleared after the flow is over.