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