类 LazyInitTargetSourceCreator

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

public class LazyInitTargetSourceCreator extends AbstractBeanFactoryTargetSourceCreator
TargetSourceCreator that enforces a LazyInitTargetSource for each bean that is defined as "lazy-init". This will lead to a proxy created for each of those beans, allowing to fetch a reference to such a bean without actually initializing the target bean instance.

To be registered as custom TargetSourceCreator for an auto-proxy creator, in combination with custom interceptors for specific beans or for the creation of lazy-init proxies only. For example, as an autodetected infrastructure bean in an XML application context definition:

 <bean class="infra.aop.proxy.BeanNameAutoProxyCreator">
   <property name="beanNames" value="*" /> <!-- apply to all beans -->
   <property name="customTargetSourceCreators">
     <list>
       <bean class="infra.aop.proxy.target.LazyInitTargetSourceCreator" />
     </list>
   </property>
 </bean>

 <bean id="myLazyInitBean" class="mypackage.MyBeanClass" lazy-init="true">
   <!-- ... -->
 </bean>
从以下版本开始:
4.0 2021/12/13 22:22
作者:
Juergen Hoeller, Sam Brannen, Harry Yang
另请参阅:
  • BeanDefinition.isLazyInit()
  • 构造器详细资料

    • LazyInitTargetSourceCreator

      public LazyInitTargetSourceCreator()
  • 方法详细资料

    • 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".

      覆盖:
      isPrototypeBased 在类中 AbstractBeanFactoryTargetSourceCreator
      另请参阅:
      • BeanDefinition.isSingleton()
    • createBeanFactoryTargetSource

      @Nullable protected 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.
      指定者:
      createBeanFactoryTargetSource 在类中 AbstractBeanFactoryTargetSourceCreator
      参数:
      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