Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] AspectJ and packages


for a fully qualified type referenced in a pointcut AspectJ uses the normal import mechanism, so you need to write:

(In source file MyAspect.aj for example)

package mypackage;
import cd.adnovum.project.*;

public aspect MyAspect {

  pointcut x() : execution(* MyClass.method(..));

}


If you don't import the type, then AspectJ looks for a type "MyClass" in the default package (and will give you a warning if it doesn't find one). The pattern:

* *.MyClass.method(..)

will match a class named MyClass in a top-level package (eg.  foo.MyClass, bar.MyClass, but not foo.bar.MyClass).  The pattern

* *..MyClass.method()

will match a class named MyClass in package with at least  one component in the name (eg. foo.MyClass and foo.bar.MyClass). Using a pattern like this matches regardless of imports.

-- Adrian
Adrian_Colyer@xxxxxxxxxx



Simon Heinzle <simon.heinzle@xxxxxxxxxx>
Sent by: aspectj-users-admin@xxxxxxxxxxx

14/03/2005 14:08

Please respond to
aspectj-users@xxxxxxxxxxx

To
aspectj-users@xxxxxxxxxxx
cc
Subject
[aspectj-users] AspectJ and packages





Has anyone an idea why pointcuts like

                execution(* ch.adnovum.project.MyClass.method(..))

work but

                execution(* MyClass.method(..))

doesn't work?? (as long as the aspect is not in the same package or does
import ch.adnovum.project.*)

I also tried * *.MyClass.method(..) but doesn't work either.

Is there an easy way to select a method of a class that is not in the
same package but does away with the whole package path in the pointcut??

Regards,
Simon
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top