Announcement Announcement Module
Collapse
No announcement yet.
@Around(@annotation(...)) not work for me Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Around(@annotation(...)) not work for me

    Hi

    I need to intercept all my method with this annotation :

    Code:
    package com.annotations;
    
    import java.lang.annotation.Documented;
    import java.lang.annotation.ElementType;
    import java.lang.annotation.Inherited;
    import java.lang.annotation.Retention;
    import java.lang.annotation.RetentionPolicy;
    import java.lang.annotation.Target;
    
    @Inherited
    @Documented
    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.RUNTIME)
    public @interface MyBatch {
    
    	BatchType batchType();
    
    }
    So, i created this class :
    Code:
    package com.common.aspects;
    
    @Aspect
    @Component
    public class AOPBatch {
    
    	@Around(@annotation(com.annotations.MyBatch )")
    	public Object logTimeMethod(ProceedingJoinPoint joinPoint) throws Throwable {
                          ...........
    	}
    }
    But when start my applications, i don’t see the poincut executed ! it is just ignored!.

    While, if i try :

    Code:
    package com.common.aspects;
    
    @Aspect
    @Component
    public class AOPBatch {
    
    	@Around(@annotation(org.springframework.transaction.annotation.Transactional)")
    	public Object logTimeMethod(ProceedingJoinPoint joinPoint) throws Throwable {
                          ...........
    	}
    }
    or :

    Code:
    package com.common.aspects;
    
    @Aspect
    @Component
    public class AOPBatch {
    
    	@Around("execution(* com.*.personal.*.al.service.impl.*.*(..))")
    	public Object logTimeMethod(ProceedingJoinPoint joinPoint) throws Throwable {
                          ...........
    	}
    }
    It's work fine.. Why??

    ps.i use :

    <spring.version>3.1.1.RELEASE</spring.version>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>${spring.version}</version>
    </dependency>

    <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.7.0</version>
    </dependency>
    Last edited by TonyGrimySpring; Jan 30th, 2013, 09:44 AM.
Working...
X