Is there a way to find out the thread information of the method which AOP intercepts, using some sort of around advice? E.g if my around advice is intercepting a login method, is there a way to obtain the information of the thread which is actually running the login method through classes like joinpointcut etc.? Thanks in advance.
Asked
Active
Viewed 753 times
1 Answers
0
use:
Thread.currentThread();
The static method java.lang.Thread.currentThread()
returns a reference to the currently executing thread object.

Ralph
- 118,862
- 56
- 287
- 383
-
Thread.currentThread() gives the reference to currently executing thread, but are you sure that the method that is being intercepted is running under the same thread as the proxy, because in Spring AOP, proxy beans are created.. so I am not sure if the same thread is responsible for executing the method and creating the proxy.. Proxy could be created by one thread and method could be executed by a different thread and both these threads could be joined at some point.. – Adithya Puram Aug 09 '13 at 13:43
-
1@Adithya Puram: It would be pretty surprising if spring creates a new thread to execute the aspect. (Except if it is the `@Async` Annotation) -- Anyway: have you tested it, or did you just ask and hope that I know the answer? – Ralph Aug 09 '13 at 14:45