• 练习生
    2021-01-10
    同一个aspect类的advice调用顺序 在源码中有体现。顺序为Around.class, Before.class, After.class, AfterReturning.class, AfterThrowing.class 来自ReflectiveAspectJAdvisorFactory类 static { Comparator<Method> adviceKindComparator = new ConvertingComparator<>( new InstanceComparator<>( Around.class, Before.class, After.class, AfterReturning.class, AfterThrowing.class), (Converter<Method, Annotation>) method -> { AspectJAnnotation<?> annotation = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method); return (annotation != null ? annotation.getAnnotation() : null); }); Comparator<Method> methodNameComparator = new ConvertingComparator<>(Method::getName); METHOD_COMPARATOR = adviceKindComparator.thenComparing(methodNameComparator); }
    展开

    作者回复: 嘿嘿,真相被你发现了

    
    2
  • 练习生
    2021-01-10
    小马哥说 advice实际上在aop中只有一种实现methodInvocation,但methodInvocation不是一个接口么,并且该接口是Joinpoint子接口,没弄明白

    作者回复: 是的,的确只有一种实现,基于 MethodInvocation 接口的

    
    