1 22 package org.jboss.test.aop.reflection; 23 24 import org.jboss.aop.joinpoint.Invocation; 25 import org.jboss.aop.reflection.ReflectionAspect; 26 27 import java.lang.reflect.Constructor ; 28 import java.lang.reflect.Field ; 29 30 33 34 public class ReflectionAspectTester extends ReflectionAspect 35 { 36 37 public static Constructor constructor; 38 public static Field field; 39 public static Object [] args; 40 public static Object retObj; 41 42 public static void clear() 43 { 44 ReflectionAspectTester.constructor = null; 45 ReflectionAspectTester.field = null; 46 ReflectionAspectTester.args = null; 47 ReflectionAspectTester.retObj = null; 48 } 49 50 protected Object interceptConstructor(Invocation invocation, 51 Constructor constructor, 52 Object [] args) 53 throws Throwable 54 { 55 56 clear(); 57 ReflectionAspectTester.constructor = constructor; 58 ReflectionAspectTester.args = args; 59 60 ReflectionAspectTester.retObj = super.interceptConstructor(invocation, constructor, args); 61 return ReflectionAspectTester.retObj; 62 } 63 64 protected Object interceptFieldRead(Invocation invocation, 65 Field field, 66 Object instance) 67 throws Throwable 68 { 69 70 clear(); 71 ReflectionAspectTester.field = field; 72 ReflectionAspectTester.retObj = super.interceptFieldRead(invocation, field, instance); 73 return ReflectionAspectTester.retObj; 74 } 75 76 protected Object interceptFieldWrite(Invocation invocation, 77 Field field, 78 Object instance, 79 Object arg) 80 throws Throwable 81 { 82 83 clear(); 84 ReflectionAspectTester.field = field; 85 ReflectionAspectTester.args = new Object []{arg}; 86 ReflectionAspectTester.retObj = super.interceptFieldWrite(invocation, field, instance, arg); 87 return ReflectionAspectTester.retObj; 88 } 89 } 90 | Popular Tags |