What are the benefits of class proxying rather than interface proxying (Spring)?

I was always very annoyed in some of the applications that I now need to support, which insist on using class proxying instead of interface proxying. More specifically, I have service level classes that are proxied, but I cannot make them final (although they should be), because for some reason, someone decided that they should be proxied by the actual class, not via an interface (although all of these classes have interfaces anyway).

Also, in order not to create an interface, is there a real reason for the proxy server through the target class, and not the proxy server based on the target interface in the Spring AOP configuration?

+3
source share
1 answer

Only if you really want the class not to change; interface proxying will be more powerful because it is more flexible, but if you really want to block everything from one implementation, class proxying is what you would do. I can imagine a situation in which one could remain dependent on a proprietary class solution, instead of allowing any interface developer to be proxy, but for me it looks like cases with edges; I usually intended to use an interface.

+4
source

Source: https://habr.com/ru/post/1712794/


All Articles