Announcement Announcement Module
Collapse
No announcement yet.
Not firing Pointcut Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Not firing Pointcut

    AOP Newbie question, so your patience appreciated...

    I want to trace my Controllers in my web application. So I created the beginings of my Aspect class.
    com.villaruz.tipunan.web is the package where my controllers are.

    Code:
    package com.villaruz.tipunan.utilities;
    
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.aspectj.lang.JoinPoint;
    import org.aspectj.lang.annotation.Aspect;
    import org.aspectj.lang.annotation.Before;
    import org.aspectj.lang.annotation.Pointcut;
    import org.springframework.stereotype.Component;
    
    @Component
    @Aspect
    public class TraceLoggerAspect{
    	/** Logger for this class and subclasses */
        protected final Log logger = LogFactory.getLog(getClass());
        
        
        @Pointcut("execution(* com.villaruz.tipunan.web..*.*(..))")    
        public void trace(){
        	logger.info("~*~*~* In TraceLogger.trace() ~*~*~*");
        }
        
        @Before("trace()")
        public void log(JoinPoint joinPoint){
        	logger.info("~*~*~* In TraceLogger.log() ~*~*~* Before calling " + 
        			joinPoint.getSignature().getName() 
    				+ " with argument " + joinPoint.getArgs()[0]);
        }
    
    }
    On my <webAppName>-servlet.xml file I let the component be scanned.

    Code:
    <context:component-scan base-package="com.villaruz.tipunan.utilities"/>
    On my application.xml file I have:
    Code:
    <aop:aspectj-autoproxy/>
    On application startup, I do see the bean created.
    However, upon execution of any of my Controller, I do not see the Aspect intercepting.

    Any help is appreciated.

  • #2
    You need a bean definition corresponding to your aspect.

    -Ramnivas

    Comment


    • #3
      Hi,
      I do see my Aspect Bean created as part of the ApplicationContext startup.
      Code:
      [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Pre-instantiating singletons in ...,traceLoggerAspect
      As it is defined for component scan
      Code:
      <context:component-scan base-package="com.villaruz.tipunan.utilities"/>
      What am I missing?

      Thanks,
      Eric

      Comment


      • #4
        None of the methods in your controller gets intercepted ?
        http://forum.springframework.org/showthread.php?t=59506

        Comment


        • #5
          Andrei

          Yes, not a single method is intercepted.
          I thought I dotted my i's and crossed my t's. This seems to be a very simple implementation, but I could not seem to figure out what is failing.

          Hope someone shed some light on this.

          -eric

          Comment


          • #6
            I reread your aspect and nothing seems to stand out. What happens when you widen your pointcut to, say,
            Code:
            execution(* com.villaruz.tipunan..*.*(..))
            -Ramnivas

            Comment

            Working...
            X