It's not a secret anymore!*
The moose likes Spring and the fly likes Dout in Around Advice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Dout in Around Advice" Watch "Dout in Around Advice" New topic
Author

Dout in Around Advice

Satyajeet Kadam
Ranch Hand

Joined: Oct 19, 2006
Posts: 215


Code containing the Aspect



Bean on which Aspect will be applied
















After Running the above program i get the output as :




After removing the comment from last method from class Asp i get the output as:



Q1) I am not able to understand second output? why DEF and Hello world is not getting printed?





Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Because with an Around type advice. You are required to call the target method. You do that by the following



Without the call to proceed() the other objects won't get called. Also in Around if the target method returns an object, you have to return it from the Around method, otherwise the client will always get null. Around is the most powerful advice type, but with power comes great responsibility. Have fun

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: Dout in Around Advice