The springAOP of pointcut using @annotation is not effective when applied to IbatisDAO

56 Views Asked by At

Annotation:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface IbatisAnno {}

Aspect:

@Component
@Aspect
public class IbatisAsepct {
    
    //not works
    @Pointcut("@annotation(xxx.IbatisAnno)")
    public void m(){}

    //works
    @Pointcut("execution(* xxx.xxDAO.*(..))")
    public void m2(){}

    @Before("m()")
    public void testM(){
        System.out.println("Before   Method...............");
    }


    @Before("m2()")
    public void testM2(){
        System.out.println("Before   Method2...............");
    }
}

Target class:

@EnableAspectJAutoProxy()
public class IbatisOfferFeedDAO extends SqlMapClientDaoSupport implements OfferFeedDAO{
   @IbatisAnno
   public void xxx(){
      this.getSqlMapClientTemplate().insert();
   }
}

Aspect does not take effect when using @Pointcut("@annotation(xxx.IbatisAnno)"), but it works when using @Pointcut("execution(* xxx.xxDAO.*(..))").

0

There are 0 best solutions below