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.Invocation; 28 import org.jboss.aop.joinpoint.MethodInvocation; 29 import org.jboss.aop.pointcut.Pointcut; 30 31 36 public class AspectPerVM 37 { 38 public int constructorCalled; 39 public int methodCalled; 40 public int fieldRead; 41 public int fieldWrite; 42 public int anotherPOJOAccess; 43 44 47 public static Pointcut anotherPOJOConstructors; 48 49 52 public static Pointcut anotherPOJOFieldReads; 53 54 57 public static Pointcut anotherPOJOFieldWrites; 58 59 62 public static Pointcut anotherPOJOPublicMethods; 63 64 67 public static Pointcut anotherPOJOFields; 68 69 72 public static Pointcut preparePOJO; 73 74 77 public Object constructorAdvice(ConstructorInvocation invocation) throws Throwable 78 { 79 System.out.println("AspectPerVM.constructorAdvice accessing: " + invocation.getConstructor().toString()); 80 constructorCalled++; 81 return invocation.invokeNext(); 82 } 83 84 87 public Object methodAdvice(MethodInvocation invocation) throws Throwable 88 { 89 System.out.println("AspectPerVM.methodAdvice accessing: " + invocation.getMethod().toString()); 90 methodCalled++; 91 return invocation.invokeNext(); 92 } 93 94 97 public Object fieldAdvice(FieldWriteInvocation invocation) throws Throwable 98 { 99 System.out.println("AspectPerVM.fieldAdvice writing to field: " + invocation.getField().getName()); 100 fieldWrite++; 101 return invocation.invokeNext(); 102 } 103 104 107 public Object fieldAdvice(FieldReadInvocation invocation) throws Throwable 108 { 109 System.out.println("AspectPerVM.fieldAdvice reading field: " + invocation.getField().getName()); 110 fieldRead++; 111 return invocation.invokeNext(); 112 } 113 114 117 public Object anotherPOJOAdvice(Invocation invocation) throws Throwable 118 { 119 System.out.println("AspectPerVM.anotherPOJOAdvice"); 120 anotherPOJOAccess++; 121 return invocation.invokeNext(); 122 } 123 124 public void reset() 125 { 126 constructorCalled = 0; 127 methodCalled = 0; 128 fieldRead = 0; 129 fieldWrite = 0; 130 anotherPOJOAccess = 0; 131 } 132 133 } 134 | Popular Tags |