Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How to access annotation values

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


Back to the top