Spring aop 001 : Enhanced order

package com.thereisnospon.spring.demo.course.imp.c004_aop;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
/**
 * If enhancements are declared in the same aspect class, they are woven in the order defined by the enhancements in the aspect class;
 *
 * If the enhancements are in different aspect classes, and these aspect classes implement the org.springframework.core.Ordered interface, it is determined by the sequence number of the interface method (the sequence number is small and weaved first);
 *
 * If the enhancements are in different aspect classes and the aspect classes do not implement the org.springframework.core.Ordered interface, the order of weaving is undefined.
 */
public class T002_Aop02_TargetThis2 {

    public static class BookService {
        public void doService() {
            System.out.println("doService");
        }
    }

    @Aspect
    @Order(value = 2)
    public static class BookAspect {
        @Before("within(com.thereisnospon.spring.demo.course.imp.c004_aop.T002_Aop02_TargetThis2.BookService)")
        public void be() {
            System.out.println("BookAspect");
        }
    }

    @Aspect
    public static class BookAspect2 implements Ordered {

        @Before("within(com.thereisnospon.spring.demo.course.imp.c004_aop.T002_Aop02_TargetThis2.BookService)")
        public void be() {
            System.out.println("BookAspect2");
        }

        @Override
        public int getOrder() {
            return 1;
        }
    }

    @Configuration
    @EnableAspectJAutoProxy(proxyTargetClass = true)
    public static class Config {
        @Bean
        public BookAspect bookAspect() {
            return new BookAspect();
        }

        @Bean
        public BookAspect2 bookAspect2() {
            return new BookAspect2();
        }

        @Bean
        public BookService bookService() {
            return new BookService();
        }
    }

    public static void test1() {
        ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
        BookService bookService = (BookService) context.getBean("bookService");
        bookService.doService();
    }

    public static void main(String[] args) {
        test1();
        /* output
        BookAspect2
        BookAspect
        doService
         */}
}