Source Code : implements AfterReturningAdvice

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

implements AfterReturningAdvice

       
File: Main.java

import java.lang.reflect.Method;

import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.framework.ProxyFactory;

public class Main {
  public static void main(String[] args) throws Exception {
    MessageWriter target = new MessageWriter();

    // create the proxy
    ProxyFactory pf = new ProxyFactory();

    pf.addAdvice(new SimpleAfterReturningAdvice());
    pf.setTarget(target);

    MessageWriter proxy = (MessageWriter) pf.getProxy();

    // write the messages
    proxy.writeMessage();
  }
}

class MessageWriter {
  public void writeMessage() {
      System.out.println("A");
  }
}
class SimpleAfterReturningAdvice implements AfterReturningAdvice {
  public void afterReturning(Object returnValue, Method method, Object[] args,
          Object target) throws Throwable {
      System.out.println("After method: " + method.getName());
  }
}




           
       

Thank with us