Subject line basically says it all. I have a static method I want to intercept so that around advice can be applied to it. I can get this to work with any non-static methods but I'm unsure how to allow static methods to be intercepted.
It may be null." So, instead of passing in an actual object, a null may be passed; therefore, a static method can be invoked without an actual instance of the class.
Yes we can. Because we are accessing the class level members.
Like a mathematical function, a Java static method can take on more than one argument, and therefore can have more than one parameter variable.
Yes, A spring bean may have static methods too.
You can't do that with Spring AOP, because it is proxy based. You have to use AspectJ. Take a look at this simple example: http://blog.jayway.com/2007/02/16/static-mock-using-aspectj/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With