public aspect Checker {
before(): get(* *) && !withincode(* get*(..)){ System.out.println(“checking…”);}
}
That is checking field-get join points not within getters. Other alternatives would include cflow() or if() clauses using thisJoinPoint - but those would both leave runtime checks in the code where the test above can be completely statically determined.
(It isn’t verifying the field name matches the getter name - that’s where you might be able to add an if() test or a check to your advice that compares thisJoinPointStaticPart with thisEnclosingJoinPointStaticPart)
cheers, Andy
I have some java beans I would like to secure using AspectJ. Like all beans the class has fields with matching setters and getters, e.g. public class Bean { private String value; public void setValue(String value) { this.value = value; } public String getValue(String value) { return value; } } I need to secure all read and write operations, e.g. for read I need to secure getValue() using an aspect, but I also need to secure the 'value' field directly. Is there away to avoid doing two checks on the get method aspect, i.e. one for the method call and one for the (nested) field mutation? Thanks for any help, Tim, _______________________________________________aspectj-users mailing listaspectj-users@xxxxxxxxxxxTo change your delivery options, retrieve your password, or unsubscribe from this list, visithttps://dev.eclipse.org/mailman/listinfo/aspectj-users
|