[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
[aspectj-users] using @annotation to select annotated aspects
|
- From: Dénes Németh <mr.nemeth.denes@xxxxxxxxx>
- Date: Sat, 14 Jan 2012 18:33:31 +0100
- Delivered-to: aspectj-users@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=9/J1rCmF20+CckLDf5rooC5JQ2r/yEavO0q+KgtBwdM=; b=jkKl4Anv+DX3yR+HXEtlHKyzc9TNhLKmnnEg2TKKLMAepUyRjOhjP+Hd/s8OQgidhw oLvUdIiBiWIesUi3K6Z+eAMRxRi0KlHJlzpKYh+1UE1nkT5ZmuayMlohsP0jwK27c5ed ifFuFzqstXnKkAgSnEoLjaT4VF+nAU2teXH+w=
Hi
Does @annotation work on aspects too? I could not come up with a
working example.
Logically I assume that the call of simple2.foo is caught by the p1
pointcut in Test2, and
since Test2 is annoted with Annotation2 than the System.out.println
call should be
caught by Test1 / p8. Is this correct?
@Retention(RetentionPolicy.RUNTIME)
public @interface Annotation2 { }
public class Simple {
public void foo2(){ System.err.print("foo2"); }
}
aspect Test1{
pointcut p8() : @annotation(Annotation2);
before () : p8() { System.out.println("p8");
}
@Annotation2
aspect Test2{
pointcut p1() : call(void Simple.foo2());
before () : p1(){ System.err.println("lexical2"); }
}
public class Main{
public static void main(String[]args){
Simple s = new Simple();
s.foo2();
}
}
Many thanks,
Denes