aspose file tools*
The moose likes Aspect Oriented Programming and the fly likes Doubt regarding Spring AOP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Aspect Oriented Programming
Bookmark "Doubt regarding Spring AOP " Watch "Doubt regarding Spring AOP " New topic
Author

Doubt regarding Spring AOP

Sumeet H Singh
Greenhorn

Joined: Jan 03, 2009
Posts: 29
Hi all,
Had a doubt regarding the spring AOP or rather AOP in general.
If I have a class having 2 methods - MethodA() and MethodB().
Before advice is applied to MethodA() so that another method(lets say MethodC()) is called before it. This works fine if you instantiate the class through ApplicationContext and call MethodA() on that instance.

Would that method be called if we call methodA() from MethodB() directly(as in, a java method call), considering that MethodB() is called on an instance instantiated through Spring's ApplicationContext??

Its not getting called..

Please clarify whether its correct as per AOP's rules or not.

Regards,
Sumeet
Kalyana Chakravarthy Gade
Greenhorn

Joined: Jan 10, 2008
Posts: 1
It will not get called because Spring AOP is proxy-based. Please see this Spring documentation link for more details.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Moving to the AOP forum.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

See this thread.

At the bottom I explain how you can configure Maven to use compile time weaving to allow for self calls without the need of the proxy.

http://www.coderanch.com/t/596257/aop/Spring-AOP


[How To Ask Questions][Read before you PM me]
Sumeet H Singh
Greenhorn

Joined: Jan 03, 2009
Posts: 29
Thanks Kalyana and Bill!


I now have a doubt in the transaction management related to this.
The transaction propagation rules are used for specifying how a method would behave if it is called from another method which is/is not running within a transaction.


Referring to the attachment, I want to implement a scenario where method-A() has "REQUIRED" propagation level and it calls method-B(), which has "NEVER" propagation level, so that it throws an exception.


How to make sure that the transaction advice defined for method-B() (which is specified through AOP code written below) gets executed if it gets called through method-A() as displayed in the figure?



Regards,
Sumeet


[Propagation Rules.png]

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Doubt regarding Spring AOP