This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Spring and the fly likes Doubt regarding advising final classes in spring.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Doubt regarding advising final classes in spring.." Watch "Doubt regarding advising final classes in spring.." New topic
Author

Doubt regarding advising final classes in spring..

Sumeet H Singh
Greenhorn

Joined: Jan 03, 2009
Posts: 29
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)


Sumeet
SCJP, SCWCD
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Sumeet H Singh
Greenhorn

Joined: Jan 03, 2009
Posts: 29
Thanks Mark !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt regarding advising final classes in spring..
 
Similar Threads
spring AOP aspect4j logger on the spring mvc application
compile time vs runtime error
Help on Assigning one Reference to another
I don't understand why