• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Doubt regarding advising final classes in spring..

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Sumeet H Singh
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mark !
 
reply
    Bookmark Topic Watch Topic
  • New Topic