Announcement Announcement Module
Collapse
No announcement yet.
how get returning object Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how get returning object

    Hello,

    I just wonder how can i get the returning object if it has?

    e.g

    public User update(User user)
    {
    ..................
    return user;
    }

    how can i get the the user object in the after advice?
    any idea?

    thanks.
    cheers.

  • #2
    You can use after returning advice or around advice. See http://static.springsource.org/sprin...rence/aop.html section 6.2.4.2.
    Here is the example provided on how to capture the return value. Of course it is much cleaner if you were to use code style advice.

    Code:
    import org.aspectj.lang.annotation.Aspect;
    import org.aspectj.lang.annotation.AfterReturning;
    
    @Aspect
    public class AfterReturningExample {
    
      @AfterReturning(
        pointcut="com.xyz.myapp.SystemArchitecture.dataAccessOperation()",
        returning="retVal")
      public void doAccessCheck(Object retVal) {
        // ...
      }
      
    }

    Comment

    Working...
    X