Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] How to "disable" aspect

Note that you can use the if() pointcut designator too, e.g.,

 

    boolean enabled = true;

 

    pointcut myPointcut(): call(* com.test.*.*(..)) && if(enabled);

 

Of course making this a final as you did Jesse allows the compiler to know not to weave (saving a runtime check).

 

Another option to disable at compile time, which Kevin summarized is

 

    pointcut never();

 

    pointcut myPointcut(): call(* com.test.*.*(..)) && never();

 

 


From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Jesse Hepburn
Sent: Wednesday, April 18, 2007 10:21 AM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] How to "disable" aspect

 

This isn't the most elegant solution, but it works if you need to turn it on and off easily...

public aspect ManagerSecurity
{
    final boolean RUN = true;

    pointcut myPointcut(): call(* com.test.*.*(..));

    before(): myPointcut() {
       if(RUN)
       {
          // Do Stuff Here
       }
    }
}

----- Original Message ----
From: Josh <gemini929@xxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Sent: Wednesday, April 18, 2007 10:14:13 AM
Subject: Re: [aspectj-users] How to "disable" aspect

Jesse,

 

Can you give me an example?

 

Joshua

 

On 4/18/07, Jesse Hepburn <jesse_hepburn@xxxxxxxxx> wrote:

I would use a constant within the pointcut to determine if it should be run or not.

----- Original Message ----
From: Josh < gemini929@xxxxxxxxx>
To: aspectj-users <aspectj-users@xxxxxxxxxxx>
Sent: Wednesday, April 18, 2007 8:14:10 AM
Subject: [aspectj-users] How to "disable" aspect

I am a beginner with AspectJ.  I have assembled several aspects which are usefull to my project.  Some aspects, like the tracing aspect, I only use

occasionally.  Is there a way to "disable" an aspect in the source code instead of removing the entire aspect from your source directory?

 

-Joshua

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
 

 

 


Ahhh...imagining that irresistible "new car" smell?
Check out new cars at Yahoo! Autos.


_______________________________________________
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

 

 


Ahhh...imagining that irresistible "new car" smell?
Check out new cars at Yahoo! Autos.


Back to the top