aspose file tools*
The moose likes Spring and the fly likes Spring AOP,  How does this example do it? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring AOP,  How does this example do it?" Watch "Spring AOP,  How does this example do it?" New topic
Author

Spring AOP, How does this example do it?

james frain
Ranch Hand

Joined: Apr 06, 2011
Posts: 36
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
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
Don't get me started about those stupid light bulbs.
 
subject: Spring AOP, How does this example do it?