|
Hi All,
well i am experiencing real troubles to test an AspectJ annotated poincut to work on Spring 3. The goal is to create a poincut that deals with methods annotated with a given customized annotation. Here is the annotation (simple one really) @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface MyAnnotation { String name(); } Here is my Aspect @Aspect @Aspect public class MyPoinCut { @Pointcut(value = "execution (@MyAnnotation * *.*(..))") public void anyTaskToPerform() { /* do domething */ } @Around("anyTaskToPerform()") public Object performCallWhenException(ProceedingJoinPoint joinPoint) throws Throwable { /* do something here too */ }} Now, here is my main class including the annotation in its methods: public class SomeJob { @MyAnnotation public letsdoit(){ /* business */ } } Ii have just a unit test calling the letsdoit method of the SomeJob class, nothing special! The problem is that it seems that the expression given to the poincut seem to be wrong and i don't know how to fix it , thus, my pointcut is just ignored and never called !! can i have some help please? Thanks |
|
Is your annotation in a package by any chance? In annotation style
pointcuts (@Pointcut) you need to fully qualify type names. I only say this because your pointcut looks OK. Are you using SpringAOP to wire it up right now or just testing by having it all in an AspectJ project? (Under AJDT in eclipse) Andy On 21 March 2011 03:14, jelramzy <[hidden email]> wrote: > Hi All, > > well i am experiencing real troubles to test an AspectJ annotated poincut to > work on Spring 3. > The goal is to create a poincut that deals with methods annotated with a > given customized annotation. > > Here is the annotation (simple one really) > > > @Retention(RetentionPolicy.RUNTIME) > @Target(ElementType.METHOD) > public @interface MyAnnotation { > String name(); > } > > Here is my Aspect @Aspect > > @Aspect > public class MyPoinCut { > > @Pointcut(value = "execution (@MyAnnotation * *.*(..))") > public void anyTaskToPerform() { > /* do domething */ > } > > > @Around("anyTaskToPerform()") > public Object performCallWhenException(ProceedingJoinPoint joinPoint) > throws Throwable { > /* do something here too */ > }} > > Now, here is my main class including the annotation in its methods: > > > public class SomeJob { > > @MyAnnotation > public letsdoit(){ > /* business */ > } > > } > > Ii have just a unit test calling the letsdoit method of the SomeJob class, > nothing special! > > The problem is that it seems that the expression given to the poincut seem > to be wrong and i don't know how to fix it , thus, my pointcut is just > ignored and never called !! > > can i have some help please? > > Thanks > > -- > View this message in context: http://aspectj.2085585.n4.nabble.com/Problems-to-set-up-an-annotation-based-pointcut-with-Spring3-and-Aspectj-1-6-tp3393103p3393103.html > Sent from the AspectJ - users mailing list archive at Nabble.com. > _______________________________________________ > aspectj-users mailing list > [hidden email] > https://dev.eclipse.org/mailman/listinfo/aspectj-users > aspectj-users mailing list [hidden email] https://dev.eclipse.org/mailman/listinfo/aspectj-users |
|
I am using Spring AOP actually ( Spring 3) and Aspectj 1.6.10.
Yes, my annotation is in a package and i tried to put the full path of my annotation and still get the same weired behaviour! |
|
the problem is that i get the following error when i try to test the pointcut:
Caused by: java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut even when i put the full path to the annotation |
|
Perhaps we need to look at the exact text of your failing program.
The error you mention suggests you are referring to a parameter in your advice that is not bound in the pointcut, like this: public Object performCallWhenException(ProceedingJoinPoint joinPoint,Object o) throws Throwable { that produces the error you are seeing. But in the code above you aren't using anything other than ProceedingJoinPoint. If you have a complete mini project that shows the problem, I'm sure we can get it sorted. cheers Andy > The problem is that GContracts is a global AST transformation which is not > taken into account by the Eclipse Groovy compiler, therefore the editor > shows the annotation closure as error but the compilation itself will run > through. On 21 March 2011 09:57, jelramzy <[hidden email]> wrote: > the problem is that i get the following error when i try to test the > pointcut: > > Caused by: java.lang.IllegalArgumentException: error at ::0 formal unbound > in pointcut > > even when i put the full path to the annotation > > -- > View this message in context: http://aspectj.2085585.n4.nabble.com/Problems-to-set-up-an-annotation-based-pointcut-with-Spring3-and-Aspectj-1-6-tp3393103p3394133.html > Sent from the AspectJ - users mailing list archive at Nabble.com. > _______________________________________________ > aspectj-users mailing list > [hidden email] > https://dev.eclipse.org/mailman/listinfo/aspectj-users > aspectj-users mailing list [hidden email] https://dev.eclipse.org/mailman/listinfo/aspectj-users |
| Powered by Nabble | Edit this page |
