org.springframework.aop.framework.autoproxy

## 类 AbstractAdvisorAutoProxyCreator

- java.lang.Object
- - org.springframework.aop.framework.ProxyConfig
  - - org.springframework.aop.framework.ProxyProcessorSupport
    - - org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
      - - org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator

- 所有已实现的接口:
    Serializable, AopInfrastructureBean, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor, org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor, org.springframework.core.Ordered
  直接已知子类:
    AspectJAwareAdvisorAutoProxyCreator, DefaultAdvisorAutoProxyCreator, InfrastructureAdvisorAutoProxyCreator

      public abstract class AbstractAdvisorAutoProxyCreator
      extends AbstractAutoProxyCreator

  Generic auto proxy creator that builds AOP proxies for specific beans based on detected Advisors for each bean.

  Subclasses may override the `findCandidateAdvisors()` method to return a custom list of Advisors applying to any object. Subclasses can also override the inherited `AbstractAutoProxyCreator.shouldSkip(java.lang.Class<?>, java.lang.String)` method to exclude certain objects from auto-proxying.

  Advisors or advices requiring ordering should implement the `Ordered` interface. This class sorts Advisors by Ordered order value. Advisors that don't implement the Ordered interface will be considered as unordered; they will appear at the end of the advisor chain in undefined order.

  作者:
    Rod Johnson, Juergen Hoeller
  另请参阅:
    `findCandidateAdvisors()`, 序列化表格

- - ### 字段概要

    - ### 从类继承的字段 org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator

      `DO_NOT_PROXY, logger, PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS`

    - ### 从接口继承的字段 org.springframework.core.Ordered

      `HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

  - ### 构造器概要

    构造器
    构造器和说明
    `AbstractAdvisorAutoProxyCreator()`

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected boolean` | `advisorsPreFiltered()` This auto-proxy creator always returns pre-filtered Advisors.
    `protected void` | `extendAdvisors(List<Advisor> candidateAdvisors)` Extension hook that subclasses can override to register additional Advisors, given the sorted Advisors obtained to date.
    `protected List<Advisor>` | `findAdvisorsThatCanApply(List<Advisor> candidateAdvisors, Class<?> beanClass, String beanName)` 判断我们候选的通知能否作用到我们当前正在创建的类上
    `protected List<Advisor>` | `findCandidateAdvisors()` Find all candidate Advisors to use in auto-proxying.
    `protected List<Advisor>` | `findEligibleAdvisors(Class<?> beanClass, String beanName)` 找到合适的增强器对象
    `protected Object[]` | `getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName, TargetSource targetSource)` Return whether the given bean is to be proxied, what additional advices (e.g.
    `protected void` | `initBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)`
    `protected boolean` | `isEligibleAdvisorBean(String beanName)` Return whether the Advisor bean with the given name is eligible for proxying in the first place.
    `void` | `setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)` 我们的AbstractAdvisorAutoProxyCreator的父类AbstractAutoProxyCreator实现了BeanFactoryAware接口 而AbstractAutoProxyCreator是我们事务 和aop导入进来的后置处理器的顶级父类 所有在实例化aop和事务导入进来的组件的 时候会调用setBeanFactory的方法来注入我们的bean工厂 调用了setBeanFactory 会触发initBeanFactory的调用来实例化我们的通知查找探测器
    `protected List<Advisor>` | `sortAdvisors(List<Advisor> advisors)` Sort advisors based on ordering.

    - ### 从类继承的方法 org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator

      `buildAdvisors, createProxy, customizeProxyFactory, determineCandidateConstructors, getBeanFactory, getCacheKey, getCustomTargetSource, getEarlyBeanReference, isFrozen, isInfrastructureClass, postProcessAfterInitialization, postProcessAfterInstantiation, postProcessBeforeInitialization, postProcessBeforeInstantiation, postProcessPropertyValues, predictBeanType, setAdvisorAdapterRegistry, setApplyCommonInterceptorsFirst, setCustomTargetSourceCreators, setFrozen, setInterceptorNames, shouldProxyTargetClass, shouldSkip, wrapIfNecessary`

    - ### 从类继承的方法 org.springframework.aop.framework.ProxyProcessorSupport

      `evaluateProxyInterfaces, getOrder, getProxyClassLoader, isConfigurationCallbackInterface, isInternalLanguageInterface, setBeanClassLoader, setOrder, setProxyClassLoader`

    - ### 从类继承的方法 org.springframework.aop.framework.ProxyConfig

      `copyFrom, isExposeProxy, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setOpaque, setOptimize, setProxyTargetClass, toString`

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### 构造器详细资料

    - #### AbstractAdvisorAutoProxyCreator

          public AbstractAdvisorAutoProxyCreator()

  - ### 方法详细资料

    - #### setBeanFactory

          public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)

      我们的AbstractAdvisorAutoProxyCreator的父类AbstractAutoProxyCreator实现了BeanFactoryAware接口 而AbstractAutoProxyCreator是我们事务 和aop导入进来的后置处理器的顶级父类 所有在实例化aop和事务导入进来的组件的 时候会调用setBeanFactory的方法来注入我们的bean工厂 调用了setBeanFactory 会触发initBeanFactory的调用来实例化我们的通知查找探测器
      指定者:
        `setBeanFactory` 在接口中 `org.springframework.beans.factory.BeanFactoryAware`
      覆盖:
        `setBeanFactory` 在类中 `AbstractAutoProxyCreator`
      参数:
        `beanFactory` -

    - #### initBeanFactory

          protected void initBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)

    - #### getAdvicesAndAdvisorsForBean

          @Nullable
          protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass,
                                                                     String beanName,
                                                                     @Nullable
                                                                     TargetSource targetSource)

      从类复制的说明: `AbstractAutoProxyCreator`
      Return whether the given bean is to be proxied, what additional advices (e.g. AOP Alliance interceptors) and advisors to apply.
      指定者:
        `getAdvicesAndAdvisorsForBean` 在类中 `AbstractAutoProxyCreator`
      参数:
        `beanClass` - the class of the bean to advise
        `beanName` - the name of the bean
        `targetSource` - the TargetSource returned by the `AbstractAutoProxyCreator.getCustomTargetSource(java.lang.Class<?>, java.lang.String)` method: may be ignored. Will be `null` if no custom target source is in use.
      返回:
        an array of additional interceptors for the particular bean; or an empty array if no additional interceptors but just the common ones; or `null` if no proxy at all, not even with the common interceptors. See constants DO_NOT_PROXY and PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS.
      另请参阅:
        `AbstractAutoProxyCreator.DO_NOT_PROXY`, `AbstractAutoProxyCreator.PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS`

    - #### findEligibleAdvisors

          protected List<Advisor> findEligibleAdvisors(Class<?> beanClass,
                                                       String beanName)

      找到合适的增强器对象
      参数:
        `beanClass` - 当前创建bean的class对象
        `beanName` - bean的name
      返回:
        the empty List, not `null`, if there are no pointcuts or interceptors
      另请参阅:
        `findCandidateAdvisors()`, `sortAdvisors(java.util.List<org.springframework.aop.Advisor>)`, `extendAdvisors(java.util.List<org.springframework.aop.Advisor>)`

    - #### findCandidateAdvisors

          protected List<Advisor> findCandidateAdvisors()

      Find all candidate Advisors to use in auto-proxying.
      返回:
        the List of candidate Advisors

    - #### findAdvisorsThatCanApply

          protected List<Advisor> findAdvisorsThatCanApply(List<Advisor> candidateAdvisors,
                                                           Class<?> beanClass,
                                                           String beanName)

      判断我们候选的通知能否作用到我们当前正在创建的类上
      参数:
        `candidateAdvisors` - 候选的增强器
        `beanClass` - 正在创建的bean的class对象
        `beanName` - beanName
      返回:
        返回合适本类的通知器
      另请参阅:
        `ProxyCreationContext.getCurrentProxiedBeanName()`

    - #### isEligibleAdvisorBean

          protected boolean isEligibleAdvisorBean(String beanName)

      Return whether the Advisor bean with the given name is eligible for proxying in the first place.
      参数:
        `beanName` - the name of the Advisor bean
      返回:
        whether the bean is eligible

    - #### sortAdvisors

          protected List<Advisor> sortAdvisors(List<Advisor> advisors)

      Sort advisors based on ordering. Subclasses may choose to override this method to customize the sorting strategy.
      参数:
        `advisors` - the source List of Advisors
      返回:
        the sorted List of Advisors
      另请参阅:
        `Ordered`, `Order`, `AnnotationAwareOrderComparator`

    - #### extendAdvisors

          protected void extendAdvisors(List<Advisor> candidateAdvisors)

      Extension hook that subclasses can override to register additional Advisors, given the sorted Advisors obtained to date.

      The default implementation is empty.

      Typically used to add Advisors that expose contextual information required by some of the later advisors.

      参数:
        `candidateAdvisors` - the Advisors that have already been identified as applying to a given bean

    - #### advisorsPreFiltered

          protected boolean advisorsPreFiltered()

      This auto-proxy creator always returns pre-filtered Advisors.
      覆盖:
        `advisorsPreFiltered` 在类中 `AbstractAutoProxyCreator`
      返回:
        whether the Advisors are pre-filtered
      另请参阅:
        `AbstractAutoProxyCreator.getAdvicesAndAdvisorsForBean(java.lang.Class<?>, java.lang.String, org.springframework.aop.TargetSource)`, `Advised.setPreFiltered(boolean)`