[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] How to access annotation values
|
Hi Andreas,
You should write something like this:
void around(): execution(@NeedPermissionGroup * hello.World.*()) {
MethodSignature signature = (MethodSignature) thisJoinPoint.getSignature();
NeedPermissionGroup ann =
signature.getMethod().getAnnotation(NeedPermissionGroup.class);
System.out.println(ann.id());
proceed();
}
[]'s
Eduardo
2006/1/1, bednarz-hannover@xxxxxx <bednarz-hannover@xxxxxx>:
> Hello Alex,
>
> how would you access the id value in the following classes:
>
> -- NeedPermissionGroup.java --
>
> package hello;
>
> @Retention(RetentionPolicy.RUNTIME)
> @Target({ElementType.METHOD,ElementType.TYPE})
> public @interface NeedPermissionGroup {
> int id() default -1;
> }
>
> -- World.java --
>
> package hello;
> public class World {
>
> @NeedPermissionGroup(id=1)
> private void output1() {
> System.out.println("output1");
> }
>
> }
>
>
> My aspect is at this time, is this enough? What should I insert at marked position ?
>
> public aspect WorldAspect {
>
>
> void around(): execution(@NeedPermissionGroup * hello.World.*()) {
>
> // ** How can I access annotation value for id (defined in World as 1)
> proceed();
>
> }
>
>
> Thank you,
>
> Andreas
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>