Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] how to refer to pointcut defined in other aspects which extend the same parent aspect?

I think that your best bet is to write the advice in the base aspect,
which then delegates to a method in the parent abstract.  I.e.-

public abstract aspect ParentAspect {
   public abstract pointcut monitorPoint();
}

public aspect AspectA extends ParentAspect {
  public pointcut monitorPoint(): execution(* *..*.main(..));

  void around(): monitorPoint(){
      //do nothing
      proceed();
  }
}

And then capture this advice in the interceptor
public aspect InterceptAspect{
  void around(): adviceexecution() && within(ParentAspect+) {
      //do something
      proceed();
  }
}

You may need to add some extra parts to the pointcut on intercept's
around advice in order to exclude other advice defined in ParentAspect
or its children.



On Fri, Aug 14, 2009 at 11:19 PM, ppkluk<imperfectluk-ppk@xxxxxxxxxxxx> wrote:
>
> Dear all,
>
>  i want to refer to pointcut defined in other aspects (say AspectA,
> AspectB) which extend the same parent aspect (say ParentAspect), without
> prior knowning the existence of AspectA and AspectB?
>
> public abstract aspect ParentAspect {
>   public abstract pointcut monitorPoint();
> }
>
> public aspect AspectA extends ParentAspect {
>   public pointcut monitorPoint(): execution(* *..*.main(..));
> }
>
> public aspect AspectB extends ParentAspect {
>   public pointcut monitorPoint(): execution(* *..*.sayHello(..));
> }
>
> i want to write an advice to match the "ParentAspect+.monitorPoint()"
>
> public aspect InterceptAspect{
>
>  //this advice don't compile, with error message: Syntax error on token
> ".", "name pattern" expected
>  void around(): ParentAspect+.monitorPoint(){
>      //do something
>      proceed();
>  }
>
> }
>
>
> could anybody tell me how to archieve my goal?
>
> thank you
>
> ppk
>
>
> --
> View this message in context: http://www.nabble.com/how-to-refer-to-pointcut-defined-in-other-aspects-which-extend-the-same-parent-aspect--tp24981874p24981874.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top