Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] abstract and concrete aspect in different packages

I can't tell from your description what's going on.
Here's a guess based on the access specifiers.

To override an abstract member (pointcut or method), it has
to be visible in the overriding scope.  So to make it
visible outside the package, change:

 from: abstract pointcut logEvents();
   to: protected abstract pointcut logEvents();

And then change the access of the overriding pointcut to
protected or public.  This is just like Java.

We'd like to have a better error message for this, e.g.,

  "pointcut SubAspect.logEvents() does not override
   SuperAspect.logEvents(), which is not visible."

Wes

Thomas Baustert wrote:
Hi,
If have the following directory structure:
src\aj\util\
- LoggingAspect.aj
src\aj\example1\
- Client.java
- Server.java
- ServerCallLoggingAspect1.aj
src\aj\example2\
- SetGetjava
- Test.java
- SetGetLoggingAspect.aj

LoggingAspect is an abstract aspect:
package aj.util;
public abstract aspect LoggingAspect {
   abstract pointcut logEvents();
   ...
}
I create utilaj.jar with: ajc -sourceroots src\aj\util -outjar utilaj.jar and utilaj.jar contains aj\util\LoggingAspect.class.
I want to use it in the following concrete aspects:
package aj.example1;
import aj.util.LoggingAspect;
public aspect ServerCallLoggingAspect1 extends LoggingAspect {
pointcut logEvents() : call(* Client.call()) || call(* Server.getData(..));
}
I use utilaj.jar with: ajc -sourceroots src\aj\example1 -aspectpath utilaj.jar and get the error: "ServerCallLoggingAspect.aj:5 inherited abstract pointcut aj.util.LoggingAspect.logEvents() is not made concrete in aj.example1.ServerCallLoggingAspect." If I rename aj.util.LoggingAspect to aj.example1.LoggingAspect, remove the import statement in ServerCallLoggingAspect and create and use utilaj.jar
again, it works. But then I can'treuse the abstract aspect for aj.example2
two.
So I remove every package name in LoggingAspect, ServerCallLoggingAspect and SetGetLoggingAspect. But then I have to import aj.example1.Client and aj.example1.Server etc. or specify the full qualified class name at the pointcut logEvents(). Because of that it makes no real sense to me to put an aspect in the same directory with the java files the aspect should be woven in. All aspects
could also be located  in one directory (e.g. ajfiles) or whereever you
want.
So the question is, is the above error a bug, or what is the reason for that? Or would it makes no sense to structure aspects like (or with)
java classes.
Thanx.





Back to the top