• 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
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

Spring AOP, How does this example do it?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finished this tutorial and have a problem grasping how or what advice code is called based on this configuration.
I understand the pointcut and when it will be called based on the pattern. I have done AOP examples before using Annotations and it was easy to see how and what code gets called for the advice. In this case is this some inbuilt Advice that is called or how , if I wanted, Could I reconfigure it to call my own advice method?

http://static.springsource.org/docs/Spring-MVC-step-by-step/part6.html
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

james frain wrote:Finished this tutorial and have a problem grasping how or what advice code is called based on this configuration.
I understand the pointcut and when it will be called based on the pattern. I have done AOP examples before using Annotations and it was easy to see how and what code gets called for the advice. In this case is this some inbuilt Advice that is called or how , if I wanted, Could I reconfigure it to call my own advice method?

http://static.springsource.org/docs/Spring-MVC-step-by-step/part6.html



That is how you configure methods to be Transactional in XML. Versus just putting @Transactional on methods. So the pointcut expression is just there to get a Proxy around any class that matches the advisor pointcut expression. the <tx:advice> part tells which methods in those classes should be transactional and what settings besides the defaults should be set. Read the tx:method part to be like Exception handling, where the first match is used. So in ProductManager all methods are Transactional, but any that start with save have all the defaults, and everything else has all the defaults, but read-only is set to true.

Hope that helps clear things up. It is Transaction configuration all here, not your standard self made AOP here, it is getting Transactions with AOP using two namespaces.

This is a big reason why using Annotations for transactions are so much easier than xml. But some people can't use Annotation so they have to use this approach.

Mark
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic