Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] annotated itd method not advised

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


Back to the top