[jboss-user] [JBoss AOP] New message: "Field annotation"
MK Song
do-not-reply at jboss.com
Tue Feb 23 16:21:42 EST 2010
User development,
A new message was posted in the thread "Field annotation":
http://community.jboss.org/message/528037#528037
Author : MK Song
Profile : http://community.jboss.org/people/mksong
Message:
--------------------------------------------------------------
Hello,
I don't know why #2 and #3 do not work in the following example.
Please, help me out.
(1) works well
<bind pointcut="field(* bank.BankAccount->*)">
(2) does not work.
<bind pointcut="field(@bank.SecurityFieldAnnotation bank.BankAccount->*)">
(3) does not work.
<bind pointcut="field(* bank.BankAccount->@bank.SecurityFieldAnnotation)">
----------------------------------------------------------------------------
package bank;
import bank.SecurityFieldAnnotation;
public class BankAccount
{
@SecurityFieldAnnotation
private int counter;
public int getCounter() { return counter; }
public void setCounter(int counter) { this.counter = counter;}
}
----------------------------------------------------------------------------
package bank;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@Target({ElementType.FIELD})
public @interface SecurityFieldAnnotation {
}
----------------------------------------------------------------------------
package bank;
import org.jboss.aop.joinpoint.*;
public class SecurityFieldAspect
{
public Object access(FieldReadInvocation invocation)
throws Throwable {
System.out.println("[DBG] access read");
return invocation.invokeNext();
}
public Object access(FieldWriteInvocation invocation)
throws Throwable {
System.out.println("[DBG] access write");
return invocation.invokeNext();
}
}
----------------------------------------------------------------------------
<aop>
<aspect class="bank.SecurityFieldAspect"
scope="PER_JOINPOINT"/>
<bind pointcut="field(* bank.BankAccount->@bank.SecurityFieldAnnotation)">
<advice name="access"
aspect="bank.SecurityFieldAspect"/>
</bind>
</aop>
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/528037#528037
More information about the jboss-user
mailing list