Results 1 to 6 of 6

Thread: Not firing Pointcut

  1. #1
    Join Date
    May 2007
    Posts
    17

    Default 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. #2
    Join Date
    Jun 2006
    Location
    SF Bay Area, California
    Posts
    524

    Default

    You need a bean definition corresponding to your aspect.

    -Ramnivas
    Ramnivas Laddad (Follow me on Twitter)
    AspectJ in Action: Enterprise AOP with Spring Applications (2nd edition). Now available!

  3. #3
    Join Date
    May 2007
    Posts
    17

    Default

    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

  4. #4
    Join Date
    Mar 2007
    Posts
    515

    Default

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

  5. #5
    Join Date
    May 2007
    Posts
    17

    Default

    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

  6. #6
    Join Date
    Jun 2006
    Location
    SF Bay Area, California
    Posts
    524

    Default

    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
    Ramnivas Laddad (Follow me on Twitter)
    AspectJ in Action: Enterprise AOP with Spring Applications (2nd edition). Now available!

Posting Permissions

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