[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ews.eclipse.technology.aspectj] Re: Trying to pick up annotations on args

Hi Dan,

From the AJ5 doc:

http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations-pointcuts-and-advice.html#package-and-parameter-annotations

"Matching on package and parameter annotations is not supported in AspectJ 1.5.0. Support for this capability may be considered in a future release."

What you have in your withMandatoryParam() is a parameter annotation - you can't write a pointcut that matches it :(

What you typically do in this scenario is annotate the type of the
parameter - you can then match on that annotation. But that's not straightforward here where the parameter type is String...


Andy.


Dan Haywood wrote:
Okay, guys, tell me what I'm doing wrong.

I have:
public class MandatoryParamFixture {
    public void withMandatoryParam(@Mandatory String param) { }
}

with:
public aspect MandatoryParamAspect {
pointcut executeArg1(String arg) : (execution(new(@Mandatory Object+, ..)) || execution(* *(@Mandatory Object+, ..)) ) && args(arg, ..);
before(Object arg): executeArg1(arg) { if (arg == null) {
throw new IllegalArgumentException("Mandatory!");
}
}
}
You get the idea? However, the executeArg1 pointcut doesn't match the method in my fixture.


I've obviously misunderstood this pointcut pattern, can anyone set me straight?

Thanks
Dan