[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
Re: [aspectj-users] Help with defining pointcut for method execution on interface hierarchy
|
- From: Andy Clement <andrew.clement@xxxxxxxxx>
- Date: Wed, 16 Sep 2009 14:25:05 -0700
- Delivered-to: aspectj-users@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=QnBT43bJ/Ij2yYoO6XFGU8sXNfYKx/8E/bP2JV32IUY=; b=RJlcqRA/hcwHet64wVoA2daLrCE8nIinWEixH4RGSRS547L4cfwnxs+0pzbH6qcBvX RngRTtQEH/V6EeakYMrkpdOd6rpzvuoC9b1RUAz0pYJnhWkKQqa8hRXNOeuHE1moOjFK AR1gnJU2X8/+0g9MiKcEw8jrqmjfKf2DQfueU=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=XYdqm95CeH0po8KfayDxrxjJ+xyYDPF97hG14zwOE6iiutXArNmCUt3USjy9VDpCfk X3aZf8q95Q+3hTRF9OVQHD8GJgSFluQGceqrwCdxBLRfYCKdDegtVkbNt26wHG4Ti0Ay rC/OxtNNx1yEVCmnlCxengvTPdJnoe/tgvdY8=
I'm afraid I can't come up with a pointcut for that. Best I could do
is something like:
aspect X {
public static boolean check(JoinPoint.StaticPart jpsp) {
Object o = ((MethodSignature)jpsp.getSignature()).getDeclaringType();
boolean b = // work out what you want...
return b;
}
before(): execution(* A+.*(..)) && if(check(thisJoinPointStaticPart)) {
System.out.println(thisJoinPoint);
}
}
where you do your extra analysis in the check() method. But this is
not a purely static match of course.
Andy
2009/9/10 Johan Haleby <johan.haleby@xxxxxxxxx>:
> Hi,
>
> I'd like to get some help to define a pointcut. I have an empty marker
> interface (A) from which several other interfaces extends e.g.
>
> public interface B extends A {
> void myMethodInB();
> }
>
> Then I have an implementation of B (BImpl) which also extends other
> interfaces that doesn't extend from A such as X, Y, and Z, e.g.
>
> public class BImpl implements B, X, Y, Z {
> public void myMethodInB() {
> ....
> }
>
> public void myMethodInX() {
> ....
> }
> ...
> }
>
> I want to define a pointcut that only intercepts methods declared in a
> subinterface of A. So for example the only method that should be intercepted
> in BImpl is the myMethodInB method since B extends A. The other methods such
> as myMethodInX should not be intercepted. Does anyone know how a pointcut
> like this would look like?
>
> Thanks
> /Johan
>
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>