Results 1 to 2 of 2

Thread: AOP on @Controller doesn't work

  1. #1

    Default 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 - com.test.tech.MyController.test(..)

    Code:
     @Pointcut("within(@org.springframework.stereotype.Controller *)")
        public void controllerBean() {}
    
     @Pointcut("execution(* com.test.tech.MyController.test(..))")
        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
    Surya

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    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...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •