Please explain me how Spring AspectJ ‘within’ expression works? I have an advice which needs to be invoked when Target.save() is called but not when when Target is called from RelationshipBean class. For this I have below expression.
Please let me know where I am doing wrong.
The within pointcut refers to any join point in the specified class, so when you add !within to a pointcut you are basically saying that you don't want the advice to apply within the class.
You may want to double check the syntax of your !within pointcut, especially the use of wild cards. For example, if I have class MyService within package test.web.services, and I have aspect Logger in package test.web.aspects and I do not want the aspect to apply the advice to MyService, the pointcut will look like
all result without a match at !within and therefore the advice will be applied.