Results 1 to 4 of 4

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

  1. #1

    Default @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 at 05:36 AM. Reason: [RESOLVED]

  2. #2
    Join Date
    Oct 2009
    Location
    chennai,india
    Posts
    6

    Default

    Can u update the error whatever ur getting in console

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    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.
    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

  4. #4

    Default [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");
        }
    }

Posting Permissions

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