Announcement Announcement Module
Collapse
No announcement yet.
@Aspect don't work : What's wrong in my config Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Aspect don't work : What's wrong in my config

    [RESOLVED]

    Hi all,

    My spring-config.xml
    Code:
    <context:annotation-config />   
    <aop:aspectj-autoproxy />   
    <context:component-scan base-package="com.xyz.csi.core.aspect" />
    My first aspect :
    Code:
    @Component
    @Aspect
    public class ServiceSecurityAspect {
    
        /** Logger. */
        private Log logger = LogFactory.getLog(this.getClass());
    
        @Pointcut("bean(*Service)")
        public void checkUserLoginPointcut(){
            logger.info("Check Service security");
        }
        @Pointcut("execution(public * *(..))")
        public void anyPublicOperation(){
            logger.info("anyPublicOperation");
        }
    }
    The object is created by spring, but the @Aspect annotation seems to be not read.

    Any idea?
    thanks.
    Last edited by jujuz; Feb 24th, 2010, 06:36 AM. Reason: [RESOLVED]

  • #2
    Can u update the error whatever ur getting in console

    Comment


    • #3
      And what should it do?! You only defined pointcuts (the WHERE) you didn't specify WHEN (Before, After, Around) to do something. So basically your aspect isn't complete.

      Comment


      • #4
        [resolved]

        OHOHO yes of course. It works now !!! I am a jackass
        it's good to have 4 eyes control.

        Thanks

        The fix ....
        Code:
        @Component
        @Aspect
        public class ServiceSecurityAspect {
        
            /** Logger. */
            private Log logger = LogFactory.getLog(this.getClass());
        
            @Before("bean(*Service)")
            public void checkUserLoginPointcut(){
                logger.info("Check Service security");
            }
            @Before("execution(public * *(..))")
            public void anyPublicOperation(){
                logger.info("anyPublicOperation");
            }
        }

        Comment

        Working...
        X