- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between JDK dynamic proxy and CGLib proxy in Spring
Spring AOP is proxy based. Spring used two types of proxy strategy one is JDK dynamic proxy and other one is CGLIB proxy.
JDK dynamic proxy is available with the JDK. It can be only proxy by interface so target class needs to implement interface. In your is implementing one or more interface then spring will automatically use JDK dynamic proxies.
On the other hand, CGLIB is a third party library which spring used for creating proxy. It can create proxy by subclassing. Spring uses CGLIB for proxy if class is not implementing interface.
|Sr. No.||Key||JDK dynamic proxy||CGLIB proxy|
|1||Basic||It can be only proxy by interface so target class needs to implement interface||It can create proxy by subclassing|
|2||Package||It is available with the Java||It is a third library.|
|3||Performance||It is a bit slow than CGLIB proxy||It is faster than JDK dynamic proxy|
|4.||Final||Final class and Final method can not be proxy||Final class and Final method can not be proxy|
|5..||Use case||Spring uses JDK proxy when is class is implementing one or more interface||Spring uses CGLib proxy when class in not implementing interface|
- Difference Between Virtual Private Network (VPN) and Proxy
- jQuery $.proxy() Method
- What are the differences between Firewall and Proxy Server?
- Difference between applicationContext.xml and spring-servlet.xml in Spring Framework
- Difference between DispatcherServlet and ContextLoaderListener in Spring
- What is a Proxy Server?
- What is Proxy Class in C++?
- Creating a Proxy Webserver in Python
- Difference between Spring AOP and AspectJ AOP
- Difference between JDK, JRE and JVM in Java
- Difference between Save and SaveAndFlush in Spring Java
- Difference between IOC and Dependency Injection in Spring.
- Difference between @Bean and @Component annotation in Spring.
- How does a Proxy Server function?