1 16 package net.sf.cglib.proxysample; 17 18 import java.lang.reflect.Method ; 19 20 import net.sf.cglib.proxy.InvocationHandler; 21 22 26 public class InvocationHandlerSample implements InvocationHandler { 27 28 private Object o; 29 30 33 public InvocationHandlerSample(Object o) { 34 this.o = o; 35 } 36 37 public Object invoke(Object proxy, Method method, Object [] args) 38 throws Throwable { 39 System.out.println("invoke() start"); 40 System.out.println(" method: " + method.getName()); 41 if (args != null) { 42 for (int i = 0; i < args.length; i++) { 43 System.out.println(" arg: " + args[i]); 44 } 45 } 46 Object r = method.invoke(o, args); 47 System.out.println(" return: " + r); 48 System.out.println("invoke() end"); 49 return r; 50 } 51 52 } 53 | Popular Tags |