Tuesday, September 17, 2013

java proxy vs CGLIB vs aspectJ

There is a good article explained the difference between java proxy, CGLIB and aspectJ.


Using transaction as an example, proxy and CGLIB is adding another class in front of the target class. AspectJ weaver adds interception logic directly into target method on target class.

For proxy and CGLIB, if there is a non-transactional method calling a transactional method on the same class, it won’t be wrapped by transaction, as the call from non-transactional method to transactional method happens inside the class itself. It does not go through the proxy or CGLIB class, but aspectJ works as the code was injected inside the method.

No comments:

Post a Comment