Hello. I would appreciate any suggestions on the following:
I’m having an hard time expressing two scenarios I
have via pointcuts. I want to declare an error anytime someone tries to instantiate
Foo() when there is an @Inject annotation anywhere else in the same class. For
instance:
public class Foo {
public Foo() {
}
public Foo(boolean bar) {
}
@Inject
public setBean() {
}
}
So as an example, “new Foo()” “new
Foo(false)” should both be matched by the pointcut.
I also want to *not* match calls from within the same class
(or it’s subclasses) to a method annotated with @Testable declared within
the same class (or superclass)
public class Foo {
public Foo() {
execute(); <--
Should not match
}
@Testable
public static void execute() {
}
}
public class Bar {
public Bar () {
Foo.execute();
<-- Should match
}
}
I’ve been able to make specific pointcuts for each class
to satisfy the behavior I want – but that’s a lot of pointcuts to
maintain. I would rather have a general pointcut for the general behavior. I
think I am just running up against a limitation of what can be expressed in
AspectJ. But I appreciate any insights anyone may have on this.
Thank you,
Nick