Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How can you access an aspect from a normal java class

The code seems right. Check your import statements and/or your Eclipse setting (AspectJ nature, inclusion of TestAspect on source path, etc.)

You may define pointcuts in a class (just as you would do in an aspect). Then you may refer to those pointcuts as MyClass.myPointcut().

-Ramnivas

On Fri, Oct 31, 2008 at 5:46 AM, Piers Powlesland <piers@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Hi

I would like to get access to an aspect from a java class so that I can set some of its fields.

I have tried the following form but Eclipse gives the error "TestAspect cannot be resolved".

Class G{

       public void setAspectField(){
               TestAspect.aspectOf().x = 0;
       }

}

aspect TestAspect{
       public int x;
}


Also is there some way to define a pointcut in an normal class and then pass it to an aspect to use for some predefined advice.

Thank you for your help

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


Back to the top