File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt regarding Spring AOP

 
Sumeet H Singh
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will not get called because Spring AOP is proxy-based. Please see this Spring documentation link for more details.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the AOP forum.

Mark
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sumeet H Singh
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
[Thumbnail for Propagation Rules.png]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic