Around IT in 256 seconds

Spring AOP riddle demystified

September 20, 2009 | 1 Minute Read

In one of my previous posts I gave you an example of some unexpected behavior when using Spring AOP proxies. Few days later I began to read "Pro Spring 2.5" by Jan Machacek, Jessica Ditt, Aleksa Vukotic and Anirvan Chakraborty. It turned out that my riddle is actually a well known problem which has more than one solution. Also one of my Readers suggested some different approach.

This almost nine-hundred-pages book has a whole section in Chapter 6: Advanced AOP introducing the problem which I believed I have discovered. There is even a programmatic solution, similar to EJB’s SessionContext.getBusinessObject(). But if the EJB method may be treated as somewhat standardized, using AopContext.currentProxy() looks awkward and unnecessarily couples you to the Spring framework. I almost feel guilty for telling you about this method and you should feel the same if you thought about using it. Luckily, authors of "Pro Spring 2.5" also discourage its use.

So if you want to have in-depth understanding of Spring AOP, I suggests you to take I look at this book. Or at least follow my blog, as I will surely present a few more concepts considering Spring AOP and AspectJ in the future. Stay tuned! Tags: aop, spring

Be the first to listen to new episodes!

To get exclusive content: