This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dout in Around Advice

 
Satyajeet Kadam
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic