Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] disabling aspects

Hi

You can use an if pointcut and a boolean "isEnable" field in the aspect:
aspect A {
  boolean isEnable = false;
  toggle() {
    isEnable = !isEnable;
  }// write deploy / undeploy instead perhaps for clarity
  ... // advice / pointcut using if(isEnable)
}
Then you can use A.aspectOf().toggle() to turn it on and off.

You can use the very same patterns using @AspectJ syntax since if()
pointcut is supported there as well.

There has been a discussion at last AOSD about that. Perhaps someone
has the notes or a link to share.

Alex

On 7/22/05, Oleg Lebedev <oleglebedev@xxxxxxxxxxxxx> wrote:
>  
> Greetings. 
>   
> Is there a way to disable aspects at runtime. Say, I know that an aspect is
> weaved in somewhere in class MangledClass, which class MyClass is going to
> instanciate. I don't want this aspect instructions to trigger when MyClass
> instanciates and then uses MangledClass. 
>   
> Also, is there a way to access an aspect from a Java class and modify it's
> public members? 
>   
> Thanks. 
>   
>  
> Oleg Lebedev 
> Software Architect 
> Waterford Research Institute 
> Phone: 801.938.1724 
> Cell: 801.209.6706 
>   
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
> 
> 
>


Back to the top