1 16 package net.sf.cglib.proxy; 17 18 import java.io.Serializable ; 19 import java.lang.reflect.Method ; 20 import java.lang.reflect.Modifier ; 21 22 26 public class TestInterceptor implements MethodInterceptor, Serializable { 27 String value; 28 29 public String getValue() { 30 return value; 31 } 32 33 public TestInterceptor(String ser) { 34 value = ser; 35 } 36 37 public TestInterceptor() { 38 } 39 40 public Object intercept(Object obj, Method method, Object [] args, MethodProxy proxy) throws Throwable { 41 System.out.println( method ); 42 Throwable e = null; 43 boolean invokedSuper = false; 44 Object retValFromSuper = null; 45 if (!Modifier.isAbstract(method.getModifiers()) && 46 invokeSuper(obj, method, args)) { 47 invokedSuper = true; 48 try { 49 retValFromSuper = proxy.invokeSuper(obj, args); 50 } catch (Throwable t) { 51 e = t; 52 } 53 } 54 return afterReturn(obj, method, args, invokedSuper, retValFromSuper, e); 55 } 56 57 public boolean invokeSuper(Object obj, Method method, Object [] args) throws Throwable { 58 return true; 59 } 60 61 public Object afterReturn(Object obj, Method method, Object [] args, 62 boolean invokedSuper, Object retValFromSuper, 63 Throwable e) throws Throwable { 64 if (e != null) 65 throw e.fillInStackTrace(); 66 return retValFromSuper; 67 } 68 } 69 | Popular Tags |