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?

Hi Andrew,

   why i want to reference to pointcut defined in other aspects is that, 
i want to be able to " capture the joinpoint that is not captured by any
other pointcut defined in a set of aspects".

   maybe my i have to revise the InterceptAspect as following:

public aspect InterceptAspect{

 //this advice don't compile, with error message: Syntax error on token ".",
"name pattern" expected

 // ==> try to capture the method execution in classes in a packages
"test.mycode" , 
 //which is not captured by other pointcut defined in ParentAspect and its
sub-aspects.

 void around(): execution(* test.mycode..*(..)) &&
!ParentAspect+.monitorPoint(){
   
    //do something interested
    System.out.println("This method execution is not captured by other
aspect, except InterceptAspect");

     proceed();
}

  i don't know how to achieve this..

  thank you.

ppk
      



Andrew Eisenberg wrote:
> 
> 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
>>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-refer-to-pointcut-defined-in-other-aspects-which-extend-the-same-parent-aspect--tp24981874p24995495.html
Sent from the AspectJ - users mailing list archive at Nabble.com.



Back to the top