Results 1 to 2 of 2

Thread: how get returning object

  1. #1
    Join Date
    Feb 2009
    Posts
    21

    Default 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. #2
    Join Date
    Aug 2008
    Location
    Vancouver, BC
    Posts
    768

    Default

    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) {
        // ...
      }
      
    }
    Andrew Eisenberg, Ph.D.
    SpringSource, a division of VMware
    SpringSource Tools Team
    More about AJDT, Groovy-Eclipse, and Grails tooling

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •