I can not understand what the proxy class that is created when I add some logic to the BeanPostProcessor after the init method differs from the proxy that is created when I add logic through Spring AOP. I understand that both Dynamic Proxy or CGlib are used there and there?
1 answer
Conceptually, BeanPostProcessor is additional processing when creating an object — ie. it is called for one object 1 time (well, in fact, 2 times - before and after the initial method), and AOP is additional logic already in the working object - and it is called as many times as necessary. Hence all the differences. Inside the proxy may not be much different. But to wrap a large number of methods / objects is much easier through aop - code will be much less. But when it is necessary to completely change an object, it is better to use the first option with BeanPostProcessor - since you do not need to wrap anything - and it is easier to create a class from scratch