Sumeet K Singh wrote:Spring generates proxies for AOP in 2 ways:
If the target object:
-implements an interface - it will use java.lang.reflect.Proxy class to generate a new class
-doesn't implement an interface - it uses CGLIB to generate a subclass and includes the necessary changes depending upon the advise
If this is the case, can spring advise final classes that implement an interface? (as there is no need to subclass our class)
Yes, it if implements an interface, Spring will create a DynamicProxy of it, the DynamicProxy just holds a reference to the real instance of the class called the target. It does not try to extend it, which you can't do with a final class.
Mark