I declared my aspects using the @Aspect annotation, but the tip does not seem to apply. The aspect works in several other projects that I have, and the main difference is that the other projects are fully connected via annotations, and this particular project is wired xml. The only bean that is an annotation is Aspect. So I'm wondering if spring aspectj supports when using aspectj-autoproxy is sensitive to the order in which beans are defined in xml.
For example, beans will be declared after aspectj-autoproxy in xml is considered for AOP points?
EDIT:
I moved <aop:aspectj-autoproxy /> until all beans are created and still fail.
Basically my code consists of:
@Component @Aspect public class SomeAspect { @Pointcut("@annotation(MyAnnotation)") public void isX() {} @After("isX()") public void XX() { System.out.println("Called aspect"); } }
And my controller has something like:
public class XController extends AbstractCommandController { @MyAnnotation public void handleX(...) {
And then spring xml:
<context:component-scan base-package="package.of.some.aspect" /> <aop:aspectj-autoproxy /> <bean id="someController" class="..." />
My previous projects captured and loaded all beans using component scanning. What is different this time.
EDIT2: Another difference is that other projects use @Controller and @RequestMethod. And in this case, I am using the derived class AbstractCommmandController. I am wondering if this applies: http://forum.springsource.org/archive/index.php/t-46637.html
Namely, that I cannot seek advice from any method other than handleRequest ().
EDIT3:
My last attempt was to override handleRequest () and apply my annotation there. Under the assumption that when spring proxies my controller, it will see the annotation and apply the advice, since it calls through a public method called from the outside. This still does not work.