类 AbstractBeanFactoryTargetSourceCreator

java.lang.Object
infra.aop.framework.autoproxy.target.AbstractBeanFactoryTargetSourceCreator
所有已实现的接口:
TargetSourceCreator, infra.beans.factory.Aware, infra.beans.factory.BeanFactoryAware, infra.beans.factory.DisposableBean
直接已知子类:
LazyInitTargetSourceCreator, QuickTargetSourceCreator

public abstract class AbstractBeanFactoryTargetSourceCreator extends Object implements TargetSourceCreator, infra.beans.factory.BeanFactoryAware, infra.beans.factory.DisposableBean
Convenient superclass for TargetSourceCreator implementations that require creating multiple instances of a prototype bean.

Uses an internal BeanFactory to manage the target instances, copying the original bean definition to this internal factory. This is necessary because the original BeanFactory will just contain the proxy instance created through auto-proxying.

Requires running in an AbstractBeanFactory.

从以下版本开始:
4.0 2021/12/13 22:24
作者:
Rod Johnson, Juergen Hoeller, Harry Yang
另请参阅:
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    private infra.beans.factory.config.ConfigurableBeanFactory
     
    private final HashMap<String,infra.beans.factory.support.StandardBeanFactory>
    Internally used StandardBeanFactory instances, keyed by bean name.
    private static final infra.logging.Logger
     
  • 构造器概要

    构造器
  • 方法概要

    修饰符和类型
    方法
    说明
    protected infra.beans.factory.support.StandardBeanFactory
    buildInternalBeanFactory(infra.beans.factory.config.ConfigurableBeanFactory containingFactory)
    Build an internal BeanFactory for resolving target beans.
    createBeanFactoryTargetSource(Class<?> beanClass, String beanName)
    Subclasses must implement this method to return a new AbstractPrototypeTargetSource if they wish to create a custom TargetSource for this bean, or null if they are not interested it in, in which case no special target source will be created.
    void
    Destroys the internal BeanFactory on shutdown of the TargetSourceCreator.
    protected final infra.beans.factory.BeanFactory
    Return the BeanFactory that this TargetSourceCreators runs in.
    protected infra.beans.factory.support.StandardBeanFactory
    Return the internal BeanFactory to be used for the specified bean.
    getTargetSource(Class<?> beanClass, String beanName)
    Create a special TargetSource for the given bean, if any.
    protected boolean
    Return whether this TargetSourceCreator is prototype-based.
    final void
    setBeanFactory(infra.beans.factory.BeanFactory beanFactory)
     

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

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

    • log

      private static final infra.logging.Logger log
    • beanFactory

      private infra.beans.factory.config.ConfigurableBeanFactory beanFactory
    • internalBeanFactories

      private final HashMap<String,infra.beans.factory.support.StandardBeanFactory> internalBeanFactories
      Internally used StandardBeanFactory instances, keyed by bean name.
  • 构造器详细资料

    • AbstractBeanFactoryTargetSourceCreator

      public AbstractBeanFactoryTargetSourceCreator()
  • 方法详细资料

    • setBeanFactory

      public final void setBeanFactory(infra.beans.factory.BeanFactory beanFactory)
      指定者:
      setBeanFactory 在接口中 infra.beans.factory.BeanFactoryAware
    • getBeanFactory

      protected final infra.beans.factory.BeanFactory getBeanFactory()
      Return the BeanFactory that this TargetSourceCreators runs in.
    • getTargetSource

      @Nullable public final TargetSource getTargetSource(Class<?> beanClass, String beanName)
      从接口复制的说明: TargetSourceCreator
      Create a special TargetSource for the given bean, if any.
      指定者:
      getTargetSource 在接口中 TargetSourceCreator
      参数:
      beanClass - the class of the bean to create a TargetSource for
      beanName - the name of the bean
      返回:
      a special TargetSource or null if this TargetSourceCreator isn't interested in the particular bean
    • getInternalBeanFactoryForBean

      protected infra.beans.factory.support.StandardBeanFactory getInternalBeanFactoryForBean(String beanName)
      Return the internal BeanFactory to be used for the specified bean.
      参数:
      beanName - the name of the target bean
      返回:
      the internal BeanFactory to be used
    • buildInternalBeanFactory

      protected infra.beans.factory.support.StandardBeanFactory buildInternalBeanFactory(infra.beans.factory.config.ConfigurableBeanFactory containingFactory)
      Build an internal BeanFactory for resolving target beans.
      参数:
      containingFactory - the containing BeanFactory that originally defines the beans
      返回:
      an independent internal BeanFactory to hold copies of some target beans
    • destroy

      public void destroy()
      Destroys the internal BeanFactory on shutdown of the TargetSourceCreator.
      指定者:
      destroy 在接口中 infra.beans.factory.DisposableBean
      另请参阅:
    • isPrototypeBased

      protected boolean isPrototypeBased()
      Return whether this TargetSourceCreator is prototype-based. The scope of the target bean definition will be set accordingly.

      Default is "true".

      另请参阅:
      • BeanDefinition.isSingleton()
    • createBeanFactoryTargetSource

      @Nullable protected abstract AbstractBeanFactoryTargetSource createBeanFactoryTargetSource(Class<?> beanClass, String beanName)
      Subclasses must implement this method to return a new AbstractPrototypeTargetSource if they wish to create a custom TargetSource for this bean, or null if they are not interested it in, in which case no special target source will be created. Subclasses should not call setTargetBeanName or setBeanFactory on the AbstractPrototypeTargetSource: This class' implementation of getTargetSource() will do that.
      参数:
      beanClass - the class of the bean to create a TargetSource for
      beanName - the name of the bean
      返回:
      the AbstractPrototypeBasedTargetSource, or null if we don't match this