[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Library of Abstract Aspects
|
Hello,
I have a library of abstract aspects which I use in two different
projects. To do that, I have created a .jar file containing the library
and put in the classpath of my two projects. Then, I simply extend the
abstract aspects and define their scope providing a definition for the
scope pointcut. For example:
public aspect MyConcreteAspect extends MyAbstractAspectFromTheLibrary {
public pointcut scope() : within(pt.zenida.paulo..);
}
So far, so good. And, testing the aspects separatedly, everything seems
to be working. Then, I tried to apply them all and I had a problem with
precedence. I have two Aspects (one related to resource pooling and
another one related to transaction management - adaptations from the
wonderful book, AspectJ in Action) and they apply to the same join
point (the closing resource one). So, I had created an aspect to define
the precedence between them (the transaction one must have less
precedence than the resource pooling one). To do that, I had put the
Aspect in the two projects where the library had been applied. It did
work! However, since they are aspects from the same library, it makes
sense that the precedence coordination comes with that library. I had
created a concrete aspect in it and tried to apply it. It worked for
one case but it didn't in the other one!!!
And there is also a second strange thing: I have an Aspect that tries
to enforce the allowed names for package names (basically, forbids any
package identifier with an upper case character - the caveat here is
that it also applies to inner classes; is this a limitation for the
current feature?). When I extend the Aspect and define its scope, it
simply doesn't seem to work. However, if I put the definition of the
pointcut in the concrete aspect, it works. Let me better demonstrate
this with a snippet of the code:
public abstract aspect CoordinateProjectPackageNameAspect extends BaseAspect {
public pointcut forbidPackageNames() :
within(*) &&
within(*A*..*) ||
within(*B*..*) ||
within(*C*..*) ||
within(*D*..*) ||
within(*E*..*) ||
within(*F*..*) ||
within(*G*..*) ||
within(*H*..*) ||
within(*I*..*) ||
within(*J*..*) ||
within(*K*..*) ||
within(*L*..*) ||
within(*M*..*) ||
within(*N*..*) ||
within(*O*..*) ||
within(*P*..*) ||
within(*Q*..*) ||
within(*R*..*) ||
within(*S*..*) ||
within(*T*..*) ||
within(*U*..*) ||
within(*V*..*) ||
within(*W*..*) ||
within(*X*..*) ||
within(*Y*..*) ||
within(*Z*..*);
declare warning :
// this defines the scope for application and the points that
// should be ignored, such as any inner class!
scopeWithExcludedPoints() &&
forbidPackageNames() : "Names representing packages should be in
all lower case";
}
public aspect ConcreteCoordinateProjectPackageNameAspect extends
CoordinateProjectPackageNameAspect {
public pointcut scope() :
within(pt.zenida.paulo.thesis.test.convention.naming..*);
public pointcut excludedPoints() :
within(pt.zenida.paulo.thesis.test.convention.naming.A.MyException) ||
within(pt.zenida.paulo.thesis.test.convention.naming.A.MyExceptionWithIncorrectName);
// this only works if I define this here. If not, it simply does not
// apply to any case. Why?
public pointcut forbidPackageNames() :
within(*) &&
within(*A*..*) ||
within(*B*..*) ||
within(*C*..*) ||
within(*D*..*) ||
within(*E*..*) ||
within(*F*..*) ||
within(*G*..*) ||
within(*H*..*) ||
within(*I*..*) ||
within(*J*..*) ||
within(*K*..*) ||
within(*L*..*) ||
within(*M*..*) ||
within(*N*..*) ||
within(*O*..*) ||
within(*P*..*) ||
within(*Q*..*) ||
within(*R*..*) ||
within(*S*..*) ||
within(*T*..*) ||
within(*U*..*) ||
within(*V*..*) ||
within(*W*..*) ||
within(*X*..*) ||
within(*Y*..*) ||
within(*Z*..*);
}
Any ideas about what this might be?
Thanks in advance. Best regards,
Paulo Zenida
----------------------------------------------------------------
Mensagem enviada usando o IMP (Internet Messaging Program).