[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] annotated itd method not advised
|
The itd method exists within the aspect, not within the target type, and so:
> public pointcut exec(Wrap w) :
> execution(@Wrap * *..*(..))
> && @annotation(w)
> && within(@ItdFilter *..*);
doesnt work. Change it to
> public pointcut exec(Wrap w) :
> execution(@Wrap * *..*(..))
> && @annotation(w);
You are already limiting who gets the Itd interface with the declare
parents statement - so this should be sufficient?
On 12/09/2007, Michael McCray <mike@xxxxxxxxxxxxxxxxx> wrote:
> Hi All,
>
> I am trying to write an aspect that advices methods that have (in this
> small example) an annotation @Wrap. This aspect does advice a class
> that has methods with this annotation, but not the below introduced
> method. Is there something I am doing wrong here? The holder of the
> method must be annoted by @ItdFilter, I have put this annoation on the
> interface "Itd" below:
>
> @ItdFilter
> public interface Itd {
> }
>
> import java.lang.annotation.Retention;
> import java.lang.annotation.RetentionPolicy;
>
> @Retention(value=RetentionPolicy.RUNTIME)
> public @interface Wrap {
> }
>
> public aspect WrapItd {
>
> public pointcut exec(Wrap w) :
> execution(@Wrap * *..*(..))
> && @annotation(w)
> && within(@ItdFilter *..*);
>
> declare parents : ((@ItdFilter *..*) && !Itd)
> implements Itd;
>
> public void Itd.method() {
> System.out.println("in method");
> }
>
> void around(Wrap w) : exec(w) {
> System.out.println("around before");
> proceed(w);
> System.out.println("around after");
> }
>
> @Wrap
> public void Itd.method2() {
> System.out.println("in method2");
> }
> }
>
> Thank you for your help,
> Mike
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>