[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Why annotations are not exposed through JoinPoint.StaticPart?

Hi,

As I mentioned at the end of the article, support for value variants
is added as compelling use cases come up.  String/enum were originally
added, since then 'int' has been added.  array has not been added and
that is what you are trying.

I've raised https://bugs.eclipse.org/bugs/show_bug.cgi?id=367042 to
cover the array case.  It won't be as straightforward as the others
though, I presume you'd want to bind multiple entries in an array or
bind a specific entry and not others.

cheers,
Andy


On 15 December 2011 11:53, Mark <mark.kharitonov@xxxxxxxxx> wrote:
> Interesting, I have not seen such usage before. But your blog does not
> explain which scenarios are supported.
>
> For instance, I have the following annotation:
> ==================================================
> package com.shunra.poc.security;
>
> import java.lang.annotation.ElementType;
> import java.lang.annotation.Retention;
> import java.lang.annotation.RetentionPolicy;
> import java.lang.annotation.Target;
>
> @Target({ ElementType.METHOD, ElementType.TYPE })
> @Retention(RetentionPolicy.RUNTIME)
> public @interface Authorize {
>  KnownRole[] allow();
> }
> ==================================================
> package com.shunra.poc.security;
>
> import org.restlet.security.Role;
>
> public enum KnownRole {
>  USER("user", "A limited user."), ADMINISTRATOR("admin", "The system
> administrator."), GUEST("guest", "A guest user.");
>
>  public final Role Value;
>  private KnownRole(String name, String description) {
>    Value = new Role(name, description);
>  }
> }
> ==================================================
>
> So, how can I use it? The following pointcut does not compile:
> ==================================================
>  // Bind just the part of the annotation of interest:
>  pointcut colouredMethods(KnownRole role):
>    execution(public @Authorize * *(..)) &&
>    @annotation(Authorize(allow = { role }));
> ==================================================
>
> It does not compile.
>
>
> --
> View this message in context: http://aspectj.2085585.n4.nabble.com/Why-annotations-are-not-exposed-through-JoinPoint-StaticPart-tp4196637p4201678.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users