I am trying to learn AOP in Spring framework for the past so many days but of no avail. I also tried to run a sample code but it did not work. Please if anyone can help me in understanding Spring's AOP both practically and theoretically. [ January 17, 2008: Message edited by: Bear Bibeault ]
Hi AOP topic is a bit different, its voculabory is new, so you will read,re-read and understand AOP slowly.
But the most simple case which can help you understand AOP is 1>You have a method in a class,whose code you cannot alter, You want some custom code to run either at very start or at end or want to handle exception from original code or best to avoid the original method call itself,based on some conditions.A proxy object with new and old code gets created which actually handles method execution.
Joined: Feb 23, 2007
I have got Spring in Action book only. I have read AOP from it but i am not able to understand from it. I am not able to understand why we use proxyinterfaces. What is the concept of proxy interfaces. ??? Basically I do understand why we are using AOP but not able to understand how we are implementing it in Spring or how we are implementing it practically. If anybody can help me understand the concepts practically then it would be of great help. Thanks in advance.
I check Spring In Action yesterday night, and I found it easy enough to understand. As Vilpesh said, there's a lot of new vocabulary where you're attacking AOP for the first time. I'd suggest you to reread the AOP chapter from the beginning, slowly, and focusing on important words like Advice, Pointcut, Proxy...
What is the concept of proxy interfaces. ???
Just think of a proxy as something that acts like your bean, with some extra functionality. Look at the following :
You can ask spring to give you an instance of MyBean, with a <bean> tag, or you can ask Spring to give you a proxy of that bean, using the same interface.
Here, you're still working on a MyInterface instance, but this time, it's a proxy of your bean. Your bean does not have a clue about AOP, but the proxy does.
Well now i have understood about proxy and its code....... but now what i am not able to understand is why are we using proxy exactly.... why not use the original bean in the first place.... another thing what is the concept of target here........ please help me clarify my concepts........... thanks in advance....
Hi Siddharth, Proxy Bean is kind of virtual Bean, where we actually map advice for particular target Functionality.
There are basically 3 parts while creating proxy bean, 1. proxyInterfaces : which is interface implemented by target bean. 2. interceptorNames : which states which advices are to apply on target bean. 3. target : which is target bean on which we need to apply advices.