• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Doubt regarding Spring AOP

 
Greenhorn
Posts: 29
  • 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
 
Greenhorn
Posts: 1
  • 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.
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the AOP forum.

Mark
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • 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.

https://coderanch.com/t/596257/aop/Spring-AOP
 
Sumeet H Singh
Greenhorn
Posts: 29
  • 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]
 
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic