Announcement Announcement Module
No announcement yet.
AOP on @Controller doesn't work Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • AOP on @Controller doesn't work

    Hello All,

    I am trying to insert an aspect to find the method execution time on my Controller (annotated with @Controller)

    I have the <aop:aspectj-autoproxy/> on my applicationContext.xml file.

    I am using the pointcut to invoke on a specific method on the controller say -

     @Pointcut("within(@org.springframework.stereotype.Controller *)")
        public void controllerBean() {}
        public void methodPointcut() {}
     @Around("controllerBean() && methodPointcut() ")
     public Object logTimeMethod(ProceedingJoinPoint joinPoint) throws Throwable {
       //do something
    This is not getting executed at all. Any thoughts would be really useful.

    Thanks & Regards

  • #2
    Please use the forum search as these questions have been answered before.

    In short Bean(Factory)PostProcessor in a parent context (ContextLoaderListener) have no influence on beans in child contexts (DispatcherServlet) and AOP is applied using this mechanism and as such your configuration is pretty much useless.

    Move it to the DispatcherServlet... Also why define a controller pointcut and a very specific method execution pointcut, seems like overkill...