aspose file tools*
The moose likes Other Application Frameworks and the fly likes Help Needed in AOP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Help Needed in AOP" Watch "Help Needed in AOP" New topic

Help Needed in AOP

Siddharth Bhargava
Ranch Hand

Joined: Feb 23, 2007
Posts: 266
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 ]
Sege Stephen
Ranch Hand

Joined: Oct 06, 2007
Posts: 51
You Know what, Get yourself a book. I would recommend Spring in Action 2. The author explained AOP very well and there are sample codes in the chapter
Vilpesh Mistry
Ranch Hand

Joined: May 27, 2003
Posts: 62
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.


Siddharth Bhargava
Ranch Hand

Joined: Feb 23, 2007
Posts: 266
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.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14687

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.

[My Blog]
All roads lead to JavaRanch
Siddharth Bhargava
Ranch Hand

Joined: Feb 23, 2007
Posts: 266
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....
Amol Juvatkar

Joined: May 16, 2005
Posts: 16
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.

kindly go through following sample, which might help you to understand in better way.

many thanks,
Amol Juvatkar
I agree. Here's the link:
subject: Help Needed in AOP