Declaring and Binding Annotated Aspects

WARNING - TOPIC NOT WRITTEN - TOPIC ID: 3477

This topic has not yet been written. The content below is from the topic description.
Declaring and binding the Aspects Open up MyAspect, and you will see that the class itself is normal, but that the class has been annotated as follows: import org.jboss.aop.Bind; import org.jboss.aop.Aspect; @Aspect public class MyAspect { @Bind (pointcut="execution(POJO->new())") public Object constructorAdvice(ConstructorInvocation invocation) throws Throwable { ... } @Bind (pointcut="execution(void POJO->method())") public Object methodAdvice(MethodInvocation invocation) throws Throwable { ... } @Bind (pointcut="set(int POJO->field)") public Object fieldAdvice(FieldReadInvocation invocation) throws Throwable { ... } @Bind (pointcut="get(int POJO->field)") public Object fieldAdvice(FieldWriteInvocation invocation) throws Throwable { ... } } The class itself is annotated with @Aspect, this declares the class as an aspect in JBoss AOP. Next each of the advice methods has been annotated with @Bind, this binds each method to the specified pointcut. So, Executions of POJO's empty constructor get intercepted by MyAspect.constructorAdvice() Executions of POJO.method() get intercepted by MyAspect.methodAdvice() reads of POJO.field get intercepted by MyAspect.fieldAdvice() (FieldReadInvocation version) writes to POJO.field get intercepted by MyAspect.fieldAdvice() (FieldWriteInvocation version)