Spring AOP, when first presented to Java programmers, seems like magic. How does it happen that we have a variable of classX and we call some method on that object, but instead, it executes some aspect before or after the method execution, or even around it, intercepting the call
The technique that Spring does is called dynamic proxy. When we have an object, which implements an interface, we can create another object—the proxy object—that also implements that interface, but each and every method implementation invokes a different object called handler, implementing the JDK interface, InvocationHandler. When a method of the interface is invoked on the proxy object, it will call the following method on the handler object: ...