Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why Spring framework use cglib and asm

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I was wondering why we need to add these jar file to class path.I have read articles however I'm still confused.I have three questions.

1. what are the functionality provided by the cglib to spring framework ?
2. what are the functionality provided by the asm to spring framework ?
3. Difference between cglib and asm ?


 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nuwan Arambage wrote:Hi,
I was wondering why we need to add these jar file to class path.I have read articles however I'm still confused.I have three questions.

1. what are the functionality provided by the cglib to spring framework ?
2. what are the functionality provided by the asm to spring framework ?
3. Difference between cglib and asm ?




So Spring does a lot of Proxying. Most of the time this is done via DynamicProxy in the JDK at runtime creates a proxy based on the classes interfaces. If you class doesn't implement any interfaces it can't create a proxy. But CGLib can create on the fly proxies by extending the class it is going to proxy.

For ASM, this does byte code weaving/instrumentation at runtime.

So these instrumentation and proxies are to add functionality to your code without you having to write that code in your code. Either by decoration/proxy or byte code instrucmentation of that code into your class.

Hope that helps clear things up for you. You are not required to add the CGLib.jar, but it you want proxies on classes with no interfaces, then you need it.

Mark
 
Nuwan Arambage
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks mark...

I got your points...........
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok . i understand cglib usage from above discussion. but what about asm?? because in spring when i am using annotated classes without any interfaces , i am getting asm ClassVisitor not found exceptions. please share if any suggestions for this.
I have not included any cglib or asm jars.


Thank you.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Chakri Wise wrote:ok . i understand cglib usage from above discussion. but what about asm?? because in spring when i am using annotated classes without any interfaces , i am getting asm ClassVisitor not found exceptions. please share if any suggestions for this.
I have not included any cglib or asm jars.


Thank you.



Easy, because CGLIB uses AMS to modify the class behaviors. CGLIB is a higher abstraction than ASM.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you elaborate on interface and instrumentation
 
Your mother is a hamster and your father smells of tiny ads!
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic