spring 注解AOP

Posted 672530440

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring 注解AOP相关的知识,希望对你有一定的参考价值。

 aspectAnnotation的切面信息,加到了AnnotationAwareAspectJAutoProxyCreator的advisorsCache属性里面去了。


解析annotationServiceImpl的时候(此时AspectAnnotation还没有解析),resolveBeforeInstantiation方法里面shouldSkip方法里面,会去spring的容器找所有有Aspect注解的类,找到aspectAnnotation,然后把aspectAnnotation的切面信息,就加到了AnnotationAwareAspectJAutoProxyCreator的advisorsCache属性里面去了。

然后在doCreateBean方法里面的initializeBean方法里面的applyBeanPostProcessorsAfterInitialization方法里面,返回jdk的动态代理:org.springframework.aop.framework.JdkDynamicAopProxy@5933aa7e,代理的 h = jdk动态代理,代理的ProxyFactory里面有AnnotationServiceImpl和切面[public void arounddd(ProceedingJoinPoint) , public void beforeee(JoinPoint), public void afterrr(JoinPoint), public void pc1()],


 

 <aop:aspectj-autoproxy/>   有这个标签才支持注解。

@Service   //首先要是一个bean,然后再是反射拿到Aspect注解。
@Aspect
public class AspectAnnotation {//注解针对的是spring所有的bean。只要满足注解条件。

    @Pointcut("execution(public * com.zhuguang.jack.annotation.*.*(..))")  
    //拦截的方法:com.zhuguang.jack.service.*.*  包下的任意方法。
    //(一个类的接口在这个包下面,实现类不在这个包下面,也属于条件符合)
    //(实现类在这个包下面,接口不在这个包下面,也属于符合条件)
    public void pc1(){}

    @Before("pc1()")
    public void beforeee(JoinPoint joinPoint) {
        System.out.println("==============beforeee 前置通知=========");
    }

    @After("pc1()")
    public void afterrr(JoinPoint joinPoint) {
        System.out.println("==============afterrr 后置通知=========");
    }

    @Around("pc1()")
    public void arounddd(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("==============arounddd  前置通知=========");
        joinPoint.proceed();
        System.out.println("==============arounddd  后置通知=========");
    }

}
public interface MyService {
    public String doSomething(String param);
    public String throwTest(String param);
}
@Service("annotationServiceImpl")
public class AnnotationServiceImpl     {
    public String doSomething(String param) {
        System.out.println("==========AnnotationServiceImpl.doSomething=========");
    }
}
public class Test2 {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath*:config" + "/spring/applicationContext-core2.xml");
        AnnotationServiceImpl as = (AnnotationServiceImpl) context.getBean("annotationServiceImpl");
        as.doSomething("Jack");  //aop起作用
    }
}

==============arounddd  前置通知=========

==============beforeee 前置通知=========

==========AnnotationServiceImpl.doSomething=========

==============arounddd  后置通知=========

==============afterrr 后置通知=========

applicationContext-core2.xml  (只有一个扫描,和开启aop注解)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:jdbc="http://www.springframework.org/schema/jdbc"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:jpa="http://www.springframework.org/schema/data/jpa"
       xmlns:util="http://www.springframework.org/schema/util" xmlns:cache="http://www.springframework.org/schema/cache"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
        http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"
       default-lazy-init="true">

    <context:component-scan base-package="com.zhuguang.jack"
                            use-default-filters="true" annotation-config="true">
    </context:component-scan>

    <aop:aspectj-autoproxy/>
</beans>

解析<aop:aspectj-autoproxy/>标签:
public class AopNamespaceHandler extends NamespaceHandlerSupport {
    @Override
    public void init() {
        registerBeanDefinitionParser("aspectj-autoproxy", new AspectJAutoProxyBeanDefinitionParser());
    }
}
public BeanDefinition parse(Element element, ParserContext parserContext) {  //element = [aop:aspectj-autoproxy: null],
        AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element);   //注册入口类,AnnotationAwareAspectJAutoProxyCreator.class,放到spring的容器
        extendBeanDefinition(element, parserContext);
        return null;
    }
xml配置aop的时候,还要解析aspect,pointcut,advisor,before,after,after-returning,around然后解析成beanDefinition加到spring的容器中去。

注解版的,只需要把<aop:aspectj-autoproxy/>标签解析成AnnotationAwareAspectJAutoProxyCreator的beanDefinition然后加到容器中去就可以了。
aspectAnnotation的切面信息,就加到了AnnotationAwareAspectJAutoProxyCreator的advisorsCache属性里面去了。
ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();   //解析apploication-core.xml文件,现在总共加了7个beandefiniton到spring的容器中,把xml文件里面的bean还有spring自己的bean都加到spring的容器中去了。
protected final void refreshBeanFactory() throws BeansException {
        try {
            DefaultListableBeanFactory beanFactory = createBeanFactory();
            beanFactory.setSerializationId(getId());
            customizeBeanFactory(beanFactory);
            loadBeanDefinitions(beanFactory);
            synchronized (this.beanFactoryMonitor) {
                this.beanFactory = beanFactory;
            }
public int loadBeanDefinitions(String location, Set<Resource> actualResources) throws BeanDefinitionStoreException {
        ResourceLoader resourceLoader = getResourceLoader();  //ClassPathXmlApplicationContext@399c4be1,
        if (resourceLoader instanceof ResourcePatternResolver) {
            try {
                Resource[] resources = ((ResourcePatternResolver) resourceLoader).getResources(location);
                int loadCount = loadBeanDefinitions(resources);  //resources = spring-source-web-master/target/classes/config/spring/applicationContext-core2.xml,
public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefinitionStoreException {
        try {
            InputStream inputStream = encodedResource.getResource().getInputStream();  //spring-source-web-master\\spring-source-web-master\\target\\classes\\config\\spring\\applicationContext-core2.xml
            try {
                InputSource inputSource = new InputSource(inputStream);
                if (encodedResource.getEncoding() != null) {
                    inputSource.setEncoding(encodedResource.getEncoding());
                }
                return doLoadBeanDefinitions(inputSource, encodedResource.getResource());
            }
            finally {
                inputStream.close();
            }
protected int doLoadBeanDefinitions(InputSource inputSource, Resource resource)
            throws BeanDefinitionStoreException {
        try {
            Document doc = doLoadDocument(inputSource, resource);  //spring-source-web-master/spring-source-web-master/target/classes/config/spring/applicationContext-core2.xml    doc = [context:component-scan: null], [aop:aspectj-autoproxy: null]]
            return registerBeanDefinitions(doc, resource);
        }
public Document loadDocument(InputSource inputSource, EntityResolver entityResolver,
            ErrorHandler errorHandler, int validationMode, boolean namespaceAware) throws Exception {
        DocumentBuilderFactory factory = createDocumentBuilderFactory(validationMode, namespaceAware);  //DocumentBuilderFactoryImpl
        DocumentBuilder builder = createDocumentBuilder(factory, entityResolver, errorHandler);   //DocumentBuilderImpl
        return builder.parse(inputSource);   //spring-source-web-master\\target\\classes\\config\\spring\\applicationContext-core2.xml
    }
public int registerBeanDefinitions(Document doc, Resource resource) throws BeanDefinitionStoreException {
        BeanDefinitionDocumentReader documentReader = createBeanDefinitionDocumentReader();  //DefaultBeanDefinitionDocumentReader
        documentReader.registerBeanDefinitions(doc, createReaderContext(resource));
    }
protected void doRegisterBeanDefinitions(Element root) {
        preProcessXml(root);
        parseBeanDefinitions(root, this.delegate);   //root = applicationCore.xml的根<beans>标签,
        postProcessXml(root);
    }
protected void parseBeanDefinitions(Element root, BeanDefinitionParserDelegate delegate) {
        if (delegate.isDefaultNamespace(root)) {
            NodeList nl = root.getChildNodes();  //便利applicationCore.xml的根节点的所有子节点,
            for (int i = 0; i < nl.getLength(); i++) {
                Node node = nl.item(i);
                if (node instanceof Element) {
                    Element ele = (Element) node;
                    if (delegate.isDefaultNamespace(ele)) {
                        parseDefaultElement(ele, delegate);
                    }
                    else {
                        delegate.parseCustomElement(ele);   //解析自定义的context:component-scan标签,aop:aspectj-autoproxy标签,
                    }
                }
            }
        }
    }
//解析自定义的context:component-scan标签

public BeanDefinition parseCustomElement(Element ele, BeanDefinition containingBd) { 
        String namespaceUri = getNamespaceURI(ele);   //http://www.springframework.org/schema/context
        NamespaceHandler handler = this.readerContext.getNamespaceHandlerResolver().resolve(namespaceUri);
        return handler.parse(ele, new ParserContext(this.readerContext, this, containingBd));   //handler = ContextNamespaceHandler,ele = context:component-scan,
    }
public NamespaceHandler resolve(String namespaceUri) {
        else {
            String className = (String) handlerOrClassName;
            try {
                Class<?> handlerClass = ClassUtils.forName(className, this.classLoader);
                NamespaceHandler namespaceHandler = (NamespaceHandler) BeanUtils.instantiateClass(handlerClass);   //ContextNamespaceHandler,是一个NamespaceHandler
                namespaceHandler.init();
                handlerMappings.put(namespaceUri, namespaceHandler);
                return namespaceHandler;
            }
        }
    }
public class ContextNamespaceHandler extends NamespaceHandlerSupport {
    @Override
    public void init() {
        registerBeanDefinitionParser("component-scan", new ComponentScanBeanDefinitionParser());    //解析context:component-sca标签的类加到ContextNamespaceHandler 进去
    }
}
public BeanDefinition parse(Element element, ParserContext parserContext) {
        return findParserForElement(element, parserContext).parse(element, parserContext);    //根据element = context:component-scan找到这个标签对应的解析类ComponentScanBeanDefinitionParser,
    }
public BeanDefinition parse(Element element, ParserContext parserContext) {
        String[] basePackages = StringUtils.tokenizeToStringArray(element.getAttribute(BASE_PACKAGE_ATTRIBUTE),
                ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);   //[com.zhuguang.jack]

        // Actually scan for bean definitions and register them.
        ClassPathBeanDefinitionScanner scanner = configureScanner(parserContext, element);   //ClassPathBeanDefinitionScanner
        Set<BeanDefinitionHolder> beanDefinitions = scanner.doScan(basePackages);  //aspectAnnotation,annotationServiceImpl这2个bean的定义,加到spring容器中去,
        registerComponents(parserContext.getReaderContext(), beanDefinitions, element);

        return null;
    }
protected Set<BeanDefinitionHolder> doScan(String... basePackages) {
        Assert.notEmpty(basePackages, "At least one base package must be specified");
        Set<BeanDefinitionHolder> beanDefinitions = new LinkedHashSet<BeanDefinitionHolder>();
        for (String basePackage : basePackages) {
            Set<BeanDefinition> candidates = findCandidateComponents(basePackage);   //这个包下面只有2个类要解析,[class [AnnotationServiceImpl];spring-source-web-master\\target\\classes\\com\\zhuguang\\jack\\annotation\\AnnotationServiceImpl.class],
[AspectAnnotation];spring-source-web-master\\target\\classes\\com\\zhuguang\\jack\\annotation\\AspectAnnotation.class]]
            for (BeanDefinition candidate : candidates) {
                ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(candidate);
                candidate.setScope(scopeMetadata.getScopeName());
                String beanName = this.beanNameGenerator.generateBeanName(candidate, this.registry);
                if (checkCandidate(beanName, candidate)) {
                    BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(candidate, beanName);
                    definitionHolder = AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, definitionHolder, this.registry);
                    beanDefinitions.add(definitionHolder);
                    registerBeanDefinition(definitionHolder, this.registry);   //aspectAnnotation,annotationServiceImpl这2个bean的定义,加到spring容器中去,
                }
            }
        }
        return beanDefinitions;
    }
protected void registerComponents(
            XmlReaderContext readerContext, Set<BeanDefinitionHolder> beanDefinitions, Element element) {
        if (annotationConfig) {
            Set<BeanDefinitionHolder> processorDefinitions =
                    AnnotationConfigUtils.registerAnnotationConfigProcessors(readerContext.getRegistry(), source);   //加了4个bean到spring的容器[CommonAnnotationBeanPostProcessor]; [ConfigurationClassPostProcessor];  [RequiredAnnotationBeanPostProcessor];  [AutowiredAnnotationBeanPostProcessor];  是注解配置的处理器。
            for (BeanDefinitionHolder processorDefinition : processorDefinitions) {
                compositeDef.addNestedComponent(new BeanComponentDefinition(processorDefinition));
            }
        }

        readerContext.fireComponentRegistered(compositeDef);
    }

解析aop:aspectj-autoproxy标签:
public BeanDefinition parseCustomElement(Element ele, BeanDefinition containingBd) {
        String namespaceUri = getNamespaceURI(ele);  //http://www.springframework.org/schema/aop
        NamespaceHandler handler = this.readerContext.getNamespaceHandlerResolver().resolve(namespaceUri);
        return handler.parse(ele, new ParserContext(this.readerContext, this, containingBd));
    }
public NamespaceHandler resolve(String namespaceUri) {
        else {
            String className = (String) handlerOrClassName;
            try {
                Class<?> handlerClass = ClassUtils.forName(className, this.classLoader);
                NamespaceHandler namespaceHandler = (NamespaceHandler) BeanUtils.instantiateClass(handlerClass);   //AopNamespaceHandler,是一个NamespaceHandler
                namespaceHandler.init();
                handlerMappings.put(namespaceUri, namespaceHandler);
                return namespaceHandler;
            }
        }
    }
public BeanDefinition parse(Element element, ParserContext parserContext) {
        return findParserForElement(element, parserContext).parse(element, parserContext);   //找到aop:aspectj-autoproxy对应的解析器AspectJAutoProxyBeanDefinitionParser,
    }
public BeanDefinition parse(Element element, ParserContext parserContext) {
        AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element);    //AnnotationAwareAspectJAutoProxyCreator的bean定义加到spring的容器,
        extendBeanDefinition(element, parserContext);
        return null;
    }
现在总共加了7个beandefiniton到spring的容器中
CommonAnnotationBeanPostProcessor; ConfigurationClassPostProcessor; RequiredAnnotationBeanPostProcessor;AutowiredAnnotationBeanPostProcessor;(这4个是spring自己加的)。
AspectAnnotation;(component-scan出的自己写的类)
AnnotationServiceImpl;(component-scan出的自己写的类)
AnnotationAwareAspectJAutoProxyCreator;(<aop:aspectj-autoproxy/>标签对应的beanDefinition)
registerBeanPostProcessors(beanFactory);    
实例化实现了BeanPostProcessor接口的6个bean:[internalAutowiredAnnotationProcessor, internalRequiredAnnotationProcessor, internalCommonAnnotationProcessor, internalAutoProxyCreator, ConfigurationClassPostProcessor.importAwareProcessor, ConfigurationClassPostProcessor.enhancedConfigurationProcessor]
finishBeanFactoryInitialization(beanFactory);  
beanFactory.preInstantiateSingletons();     
//实例化9个bean,[annotationServiceImpl, aspectAnnotation, (没有解析成bean实例)。internalConfigurationAnnotationProcessor, internalAutowiredAnnotationProcessor, internalRequiredAnnotationProcessor, internalCommonAnnotationProcessor, internalAutoProxyCreator, ConfigurationClassPostProcessor.importAwareProcessor, ConfigurationClassPostProcessor.enhancedConfigurationProcessor(已经解析成实例了)。
解析annotationServiceImpl (里面有切面的类,先解析的这个类)
protected Object createBean(final String beanName, final RootBeanDefinition mbd, final Object[] args) {
        try {
            Object bean = resolveBeforeInstantiation(beanName, mbd);  //null。aspectAnnotation的切面信息,就加到了AnnotationAwareAspectJAutoProxyCreator的advisorsCache属性里面去了。
            if (bean != null) {
                return bean;
            }
        }
        Object beanInstance = doCreateBean(beanName, mbd, args);
        return beanInstance;//返回jdk的动态代理,org.springframework.aop.framework.JdkDynamicAopProxy@5933aa7e,代理的h = jdk动态代理,代理的ProxyFactory里面有AnnotationServiceImpl和切面[public void arounddd(ProceedingJoinPoint) , public void beforeee(JoinPoint), public void afterrr(JoinPoint), public void pc1()],
    }
protected Object resolveBeforeInstantiation(String beanName, RootBeanDefinition mbd) {
        Object bean = null;
        if (!Boolean.FALSE.equals(mbd.beforeInstantiationResolved)) {
            // Make sure bean class is actually resolved at this point.
            if (mbd.hasBeanClass() && !mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) {
                bean = applyBeanPostProcessorsBeforeInstantiation(mbd.getBeanClass(), beanName);   //null,aspectAnnotation的切面信息,就加到了AnnotationAwareAspectJAutoProxyCreator的advisorsCache属性里面去了。
                if (bean != null) {
                    bean = applyBeanPostProcessorsAfterInitialization(bean, beanName);
                }
            }
            mbd.beforeInstantiationResolved = (bean != null);
        }
        return bean;
    }
protected Object applyBeanPostProcessorsBeforeInstantiation(Class<?> beanClass, String beanName){
        for (BeanPostProcessor bp : getBeanPostProcessors()) {
            if (bp instanceof InstantiationAwareBeanPostProcessor) {
                InstantiationAwareBeanPostProcessor ibp = (InstantiationAwareBeanPostProcessor) bp;
                Object result = ibp.postProcessBeforeInstantiation(beanClass, beanName);   //ConfigurationClassPostProcessor.enhancedConfigurationProcessor(没做什么事),CommonAnnotationBeanPostProcessor(没做什么事),AutowiredAnnotationBeanPostProcessor(没做什么事),RequiredAnnotationBeanPostProcessor(没做什么事),AnnotationAwareAspectJAutoProxyCreator(<aop:aspectj-autoproxy/>标签对应的beanDefinition),aspectAnnotation的切面信息,就加到了AnnotationAwareAspectJAutoProxyCreator的advisorsCache属性里面去了。
                if (result != null) {
                    return result;
                }
            }
        }
        return null;
    }
AnnotationAwareAspectJAutoProxyCreator(<aop:aspectj-autoproxy/>标签对应的beanDefinition)的postProcessBeforeInstantiation方法。
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
if (isInfrastructureClass(beanClass) || shouldSkip(beanClass, beanName)) {  //aspectAnnotation的切面信息,就加到了AnnotationAwareAspectJAutoProxyCreator的advisorsCache属性里面去了。
                this.advisedBeans.put(cacheKey, Boolean.FALSE);
                return null;
            }
        if (beanName != null) {
            TargetSource targetSource = getCustomTargetSource(beanClass, beanName);   //null就什么都不做。
            if (targetSource != null) {
                this.targetSourcedBeans.add(beanName);
                Object[] specificInterceptors = getAdvicesAndAdvisorsForBean(beanClass, beanName, targetSource);
                Object proxy = createProxy(beanClass, beanName, specificInterceptors, targetSource);
                this.proxyTypes.put(cacheKey, proxy.getClass());
                return proxy;
            }
        }
        return null;
    }
protected boolean shouldSkip(Class<?> beanClass, String beanName) {
        List<Advisor> candidateAdvisors = findCandidateAdvisors();  //aspectAnnotation的切面信息,就加到了AnnotationAwareAspectJAutoProxyCreator的advisorsCache属性里面去了。
        for (Advisor advisor : candidateAdvisors) {
            if (advisor instanceof AspectJPointcutAdvisor) {
                if (((AbstractAspectJAdvice) advisor.getAdvice()).getAspectName().equals(beanName)) {  //一个都不是
                    return true;
                }
            }
        }
        return super.shouldSkip(beanClass, beanName);
    }
protected List<Advisor> findCandidateAdvisors() {
        List<Advisor> advisors = super.findCandidateAdvisors();   //null
        advisors.addAll(this.aspectJAdvisorsBuilder.buildAspectJAdvisors());   //this = AnnotationAwareAspectJAutoProxyCreatoraspectAnnotation的切面信息,就加到了AnnotationAwareAspectJAutoProxyCreator的advisorsCache属性里面去了。
        return advisors;
    }
public List<Advisor> buildAspectJAdvisors() {   //第二次从缓存advisorsCache中获取。
        List<String> aspectNames = null;
        synchronized (this) {
            aspectNames = this.aspectBeanNames;
            if (aspectNames == null) {
                List<Advisor> advisors = new LinkedList<Advisor>();
                aspectNames = new LinkedList<String>();
                String[] beanNames =
                        BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.beanFactory, Object.class, true, false);    //拿到spring容器所有的Object.class,就是所有的bean,
                for (String beanName : beanNames) {
                    if (this.advisorFactory.isAspect(beanType)) {   //有没有Aspect注解,aspectAnnotation有这个注解,
                        aspectNames.add(beanName);
                        AspectMetadata amd = new AspectMetadata(beanType, beanName);
                        if (amd.getAjType().getPerClause().getKind() == PerClauseKind.SINGLETON) {
                            MetadataAwareAspectInstanceFactory factory =
                                    new BeanFactoryAspectInstanceFactory(this.beanFactory, beanName);
                            List<Advisor> classAdvisors = this.advisorFactory.getAdvisors(factory);   //拿到aspectAnnotation的所有切面,
                            if (this.beanFactory.isSingleton(beanName)) {
                                this.advisorsCache.put(beanName, classAdvisors);    ////this = AnnotationAwareAspectJAutoProxyCreator,aspectAnnotation的切面信息,就加到了AnnotationAwareAspectJAutoProxyCreator的advisorsCache属性里面去了。
                            }
                            advisors.addAll(classAdvisors);
                        }
                    }
                }
                this.aspectBeanNames = aspectNames;
                return advisors; // [expression [pc1()];
//advice method [public void arounddd(ProceedingJoinPoint) ]; expression [pc1()]; 
//advice method [public beforeee(JoinPoint)]; expression [pc1()]; 
//advice method [public void afterrr(JoinPoint)]; ]
            }
        }
    }
public static String[] beanNamesForTypeIncludingAncestors(
            ListableBeanFactory lbf, Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) {
        String[] result = lbf.getBeanNamesForType(type, includeNonSingletons, allowEagerInit);   //拿到spring容器所有的Object.class,就是所有的bean,lbf是bean工厂。
        return result;
    }
public List<Advisor> getAdvisors(MetadataAwareAspectInstanceFactory maaif) {
        final Class<?> aspectClass = maaif.getAspectMetadata().getAspectClass();   //class com.zhuguang.jack.annotation.AspectAnnotation
        final String aspectName = maaif.getAspectMetadata().getAspectName();   //aspectAnnotation
        final List<Advisor> advisors = new LinkedList<Advisor>();
        for (Method method : getAdvisorMethods(aspectClass)) {  //[public void arounddd(ProceedingJoinPoint) , public void beforeee(JoinPoint), public void afterrr(JoinPoint), public void pc1()],
            Advisor advisor = getAdvisor(method, lazySingletonAspectInstanceFactory, advisors.size(), aspectName);
            if (advisor != null) {
                advisors.add(advisor);
            }
        }
        return advisors; // [expression [pc1()];
advice method [public void arounddd(ProceedingJoinPoint) ]; expression [pc1()]; 
advice method [public beforeee(JoinPoint)]; expression [pc1()]; 
advice method [public void afterrr(JoinPoint)]; ]
    }
private List<Method> getAdvisorMethods(Class<?> aspectClass) {
        final List<Method> methods = new LinkedList<Method>();
        ReflectionUtils.doWithMethods(aspectClass, new ReflectionUtils.MethodCallback() {
            @Override
            public void doWith(Method method) throws IllegalArgumentException {
                // 没有@Pointcut注解的方法,加进去,@Pointcut不要,只处理@before,@after,@around。
                if (AnnotationUtils.getAnnotation(method, Pointcut.class) == null) {
                    methods.add(method);
                }
            }
        });
        Collections.sort(methods, METHOD_COMPARATOR);
        return methods;   //拿到所有的方法
//[public void arounddd(ProceedingJoinPoint) , public void beforeee(JoinPoint), public void afterrr(JoinPoint), public void pc1()],包括父类的方法。
    }