Home > Back-end >  Get the caller information in spring aop
Get the caller information in spring aop

Time:10-13

Recently do aop log to record the monitoring method of the caller
Aop logs, for example, in the method A and method B runtime invokes the method A, need to be able to access when logging method to A caller is recorded B
Is there any good method? !

CodePudding user response:

Unknown detail and only one way to show you
Thread. CurrentThread (). The getStackTrace ()

CodePudding user response:

reference 1st floor maradona1984 response:
't, only one way to show you
Thread. CurrentThread (). The getStackTrace ()

This is can get the call stack but the question is how to get the caller
With a framework calls after relationship is very complicated and I will get the caller in the middle of the array location variable method for determining the index of the B

CodePudding user response:

reference 1st floor maradona1984 response:
't, only one way to show you
Thread. CurrentThread (). The getStackTrace ()

So I asked the problem is how to get what I want is that I think really the caller's class and method

CodePudding user response:

reference 3 floor longitudinal horse drink mistbow reply:
Quote: refer to 1st floor maradona1984 response:
't, only one way to show you
Thread. CurrentThread (). The getStackTrace ()

So I asked the problem is how to get what I want is that I think really the caller's class and method

From the application point of view, this access is truly the caller, what do you think of is in the code to write the caller is not clear what you need to do, which need to filter out the proxy class

CodePudding user response:

reference 5 floor maradona1984 reply:
Quote: refer to the third floor longitudinal horse drink mistbow reply:

Quote: refer to 1st floor maradona1984 response:
't, only one way to show you
Thread. CurrentThread (). The getStackTrace ()

So I asked the problem is how to get what I want is that I think really the caller's class and method

From the application point of view, this access is truly the caller, what do you think of is in the code to write the caller is not clear what you need to do, which need to filter out the proxy class

Yes I is to accurately obtain the logically the caller to filter out those I don't pay attention to the caller
Function, for example,
Method A have more than one caller I hope to record what time which method to invoke the method A
This feeling is just by stack can't distinguish want to know in the spring framework provides the ability to do this or have any good logic can get my attention on the logic of the caller and ignore distractions in the actual execution

CodePudding user response:

refer to 6th floor longitudinal horse drink mistbow reply:
Quote: refer to the 5 floor maradona1984 response:
Quote: refer to 3rd floor longitudinal horse drink mistbow reply:

Quote: refer to 1st floor maradona1984 response:
't, only one way to show you
Thread. CurrentThread (). The getStackTrace ()

So I asked the problem is how to get what I want is that I think really the caller's class and method

From the application point of view, this access is truly the caller, what do you think of is in the code to write the caller is not clear what you need to do, which need to filter out the proxy class

Yes I is to accurately obtain the logically the caller to filter out those I don't pay attention to the caller
Function, for example,
Method A have more than one caller I hope to record what time which method to invoke the method A
This feeling is just by stack can't distinguish want to know in the spring framework provides the ability to do this or have any good logic can get my attention on the logic of the caller and ignore the disturbance term in the actual execution

Proxy objects all have $XXX this type name behind, can according to ignore this rule

CodePudding user response:

This simple aop aspects, injection @ Aspect think how listen to how to monitor

CodePudding user response:

refer to the eighth floor liu137756 response:
this simple aop aspects, injection @ Aspect think how listen to how to monitor

The forehead feel irrelevant answer can say in detail?

CodePudding user response:

Unknown detail and only one way to show you
Thread. CurrentThread (). The getStackTrace ()

CodePudding user response:

I also met, the original poster to how to solve? After frame position determination
  • Related