1 22 import org.jboss.aop.joinpoint.Invocation; 23 import org.jboss.aop.joinpoint.ConstructorInvocation; 24 import org.jboss.aop.joinpoint.MethodInvocation; 25 import org.jboss.aop.joinpoint.FieldReadInvocation; 26 import org.jboss.aop.joinpoint.FieldWriteInvocation; 27 import org.jboss.aop.advice.Interceptor; 28 29 34 public class AspectPerVM 35 { 36 public int constructorCalled; 37 public int methodCalled; 38 public int fieldRead; 39 public int fieldWrite; 40 41 public Object constructorAdvice(ConstructorInvocation invocation) throws Throwable 42 { 43 System.out.println("AspectPerVM.constructorAdvice accessing: " + invocation.getConstructor().toString()); 44 constructorCalled++; 45 return invocation.invokeNext(); 46 } 47 48 public Object methodAdvice(MethodInvocation invocation) throws Throwable 49 { 50 System.out.println("AspectPerVM.methodAdvice accessing: " + invocation.getMethod().toString()); 51 methodCalled++; 52 return invocation.invokeNext(); 53 } 54 55 public Object fieldAdvice(FieldWriteInvocation invocation) throws Throwable 56 { 57 System.out.println("AspectPerVM.fieldAdvice writing to field: " + invocation.getField().getName()); 58 fieldWrite++; 59 return invocation.invokeNext(); 60 } 61 62 public Object fieldAdvice(FieldReadInvocation invocation) throws Throwable 63 { 64 System.out.println("AspectPerVM.fieldAdvice reading field: " + invocation.getField().getName()); 65 fieldRead++; 66 return invocation.invokeNext(); 67 } 68 } 69 | Popular Tags |