Hi there, I am using the AspectJ5 style annotations and in addition I also want to create a point-cut based on a custom Annotation (PermissionRequired), my Annotation looks like this -
@Retention(RetentionPolicy.RUNTIME) @Target(value = ElementType.METHOD) public @interface PermissionRequired { int mode() default -1; int user() default -1; int group() default -1; public final static int IS_DBA = 04; public final static int IS_OWNER = 02; public final static int IS_MEMBER = 40; } And an example use of this is - @PermissionRequired(user = IS_DBA) private void setOwnerId(int ownerId) { ... } I need to be able to access the values of mode, user and group from the PermissionRequired annotation in my aspect advice. My aspect looks like this - @Aspect public class PermissionRequiredAspect { @Pointcut("execution(@org.exist.security.PermissionRequired * *(..)) && this(permission) && @annotation(permissionRequired)") public void methodWithPermissionRequired(Permission permission, PermissionRequired permissionRequired) { } @Before("methodWithPermissionRequired(permission, permissionRequired)") public void enforcePermissions(JoinPoint joinPoint, Permission permission, PermissionRequired permissionRequired) { System.out.println("POINTCUT"); } Now the above works quite nicely, however after reading the following articles, http://andrewclement.blogspot.com/2009/02/aspectj-optimized-annotation-value.html http://www.eclipse.org/aspectj/doc/released/README-167.html https://bugs.eclipse.org/bugs/show_bug.cgi?id=234943 I feel that it would be nicer, and perhaps more performant to directly bind the values from the PermissionRequired annotation rather than the annotation itself. So I tried to modify my aspect appropriately - @Aspect public class PermissionRequiredAspect { @Pointcut("execution(@org.exist.security.PermissionRequired * *(..)) && this(permission) && @annotation(org.exist.security.PermissionRequired(mode,user,group))") public void methodWithPermissionRequired(Permission permission, int mode, int user, int group) { } @Before("methodWithPermissionRequired(permission, mode, user, group)") public void enforcePermissions(JoinPoint joinPoint, Permission permission, int mode, int user, int group) { System.out.println("POINTCUT"); } } However, when I compile (I am using iajc from Ant), I get the following error messages - [iajc] /Users/aretter/NetBeansProjects/eXist-acl/src/org/exist/security/PermissionRequiredAspect.java:14 [error] Syntax error on token "execution(@org.exist.security.PermissionRequired * *(..)) && this(permission) && @annotation(org.exist.security.PermissionRequired(mode,user,group))", ")" expected [iajc] @Pointcut("execution(@org.exist.security.PermissionRequired * *(..)) && this(permission) && @annotation(org.exist.security.PermissionRequired(mode,user,group))") [iajc] [iajc] /Users/aretter/NetBeansProjects/eXist-acl/src/org/exist/security/PermissionRequiredAspect.java:15 [error] Method annotated with @Pointcut() for abstract pointcut must be abstract [iajc] public void methodWithPermissionRequired(Permission permission, int mode, int user, int group) { [iajc] [iajc] [iajc] 2 errors BUILD FAILED So my question is -- Should the above annotation value bindings be possible for int values? The values themselves are final and static, so should be able to be optimised by the compiler I guess. -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk _______________________________________________ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users