• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Spring AOP, How does this example do it?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic