<aop> ... <bind pointcut="get(private java.lang.String POJO->var1)"> <interceptor class="GetInterceptor"/> </bind> ... </aop>This bindings states that when POJO.var1 is accessed for a read, invoke the GetInterceptor.
The next one is:
... <bind pointcut="set(private java.lang.String POJO->var2)"> <interceptor class="SetInterceptor"/> </bind> ...Whenever the field POJO.var2 is written to, invoke the SetInterceptor.
The next one is:
... <bind pointcut="field(public static * POJO->*)"> <interceptor class="FieldInterceptor"/> </bind> ...Whenever any public static field in POJO is accessed for a read or a write, call the FieldInterceptor. The field expression matches both get/set of a field.
$ antIt will javac the files and then run the AOPC precompiler to manipulate the bytecode, then finally run the example. The output should read as follows:
run: [java] --- pojo.getVar1(); --- [java] <<< Entering GetInterceptor for: var1 [java] >>> Leaving GetInterceptor [java] hello [java] --- pojo.setVar2(); --- [java] <<< Entering SetInterceptor for: var2 [java] >>> Leaving SetInterceptor [java] --- pojo.getVar2(); --- [java] world [java] --- POJO.var3++; --- [java] <<< Entering FieldInterceptor for: var3 type: org.jboss.aop.joinpoint.FieldReadInvocation [java] >>> Leaving FieldInterceptor [java] <<< Entering FieldInterceptor for: var3 type: org.jboss.aop.joinpoint.FieldWriteInvocation [java] >>> Leaving FieldInterceptor