[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Pointcut primitive "this(Point)" and interfaces
|
Hi!
The AspectJ 5 Quick Reference reads:
this(Point): any join poit where the currently executing object is an
instance of Point
What does "instance of Point" match?
1. class: public class Point
2. sub-class of class: public class MyPoint extends Point
3. or abstract class: public class MyPoint extends AbstractPoint
4. interface: public class MyPoint implements Point
I have a simple pointcut that should match methods that:
1. are in/under package se.example
2. has the annotation @Transactional
3. implements the interface MyInterface
pointcut TRANSACTIONAL(Transactional transactionalAnnotation):
execution(@Transactional * se.example..*(..))
&& @annotation(transactionalAnnotation);
&& this(MyInterface);
Object around(final Transactional transactional) throws StorageException
: TRANSACTIONAL(transactional)
{
// here I actually log using log4j "Entering around(Transactional = "
+ transactional + ");
MyInterface myInterface = (MyInterace)thisJoinPoint.getThis();
...
}
I have a class that implements MyInterface and that has a method annotated
with the Transactional annotation.
This method doesn't cause the around advice to run when I use the above
pointcut. At least not always. It ran two times out of probably 50 and I
honestly don't think that I changed anything... But, who knows?
More importantly, if I remove "&& this(MyInterface)" from the pointcut then
the around advice runs. I am a 100% sure that the class implements
MyInterface and also the line
MyInterface myInterface = (MyInterace)thisJoinPoint.getThis();
doesn't cause a ClassCastException.
Why doesn't my around advice run with "&& this(MyInterface)" in the
pointcut.
Regards,
Jimisola
Does it have to be an actual object? Can it not be an implemented interface.
--
View this message in context: http://www.nabble.com/Pointcut-primitive-%22this%28Point%29%22-and-interfaces-tf1894816.html#a5181983
Sent from the AspectJ - users forum at Nabble.com.