/* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ import org.jboss.aop.joinpoint.Invocation; import org.jboss.aop.joinpoint.ConstructorInvocation; import org.jboss.aop.joinpoint.MethodInvocation; import org.jboss.aop.joinpoint.FieldReadInvocation; import org.jboss.aop.joinpoint.FieldWriteInvocation; import org.jboss.aop.advice.Interceptor; /** * * @author Bill Burke * @version $Revision: 1.3 $ */ public class AspectPerVM { public int constructorCalled; public int methodCalled; public int fieldRead; public int fieldWrite; public Object constructorAdvice(ConstructorInvocation invocation) throws Throwable { System.out.println("AspectPerVM.constructorAdvice accessing: " + invocation.getConstructor().toString()); constructorCalled++; return invocation.invokeNext(); } public Object methodAdvice(MethodInvocation invocation) throws Throwable { System.out.println("AspectPerVM.methodAdvice accessing: " + invocation.getMethod().toString()); methodCalled++; return invocation.invokeNext(); } public Object fieldAdvice(FieldWriteInvocation invocation) throws Throwable { System.out.println("AspectPerVM.fieldAdvice writing to field: " + invocation.getField().getName()); fieldWrite++; return invocation.invokeNext(); } public Object fieldAdvice(FieldReadInvocation invocation) throws Throwable { System.out.println("AspectPerVM.fieldAdvice reading field: " + invocation.getField().getName()); fieldRead++; return invocation.invokeNext(); } }