1 22 package org.jboss.test.aop.annotated; 23 24 import org.jboss.aop.joinpoint.ConstructorInvocation; 25 import org.jboss.aop.joinpoint.FieldReadInvocation; 26 import org.jboss.aop.joinpoint.FieldWriteInvocation; 27 import org.jboss.aop.joinpoint.MethodInvocation; 28 29 34 public class AspectPerClass 35 { 36 public int constructorCalled; 37 public int methodCalled; 38 public int fieldRead; 39 public int fieldWrite; 40 41 44 public Object constructorAdvice(ConstructorInvocation invocation) throws Throwable 45 { 46 System.out.println("AspectPerClass.constructorAdvice accessing: " + invocation.getConstructor().toString()); 47 constructorCalled++; 48 return invocation.invokeNext(); 49 } 50 51 54 public Object methodAdvice(MethodInvocation invocation) throws Throwable 55 { 56 System.out.println("AspectPerClass.methodAdvice accessing: " + invocation.getMethod().toString()); 57 methodCalled++; 58 return invocation.invokeNext(); 59 } 60 61 64 public Object fieldAdvice(FieldWriteInvocation invocation) throws Throwable 65 { 66 System.out.println("AspectPerClass.fieldAdvice writing to field: " + invocation.getField().getName()); 67 fieldWrite++; 68 return invocation.invokeNext(); 69 } 70 71 74 public Object fieldAdvice(FieldReadInvocation invocation) throws Throwable 75 { 76 System.out.println("AspectPerClass.fieldAdvice reading field: " + invocation.getField().getName()); 77 fieldRead++; 78 return invocation.invokeNext(); 79 } 80 81 public void reset() 82 { 83 constructorCalled = 0; 84 methodCalled = 0; 85 fieldRead = 0; 86 fieldWrite = 0; 87 } 88 } 89 | Popular Tags |