TargetSourceCreatorthat enforces a
LazyInitTargetSourcefor 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="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <property name="beanNames" value="*" /> <!-- apply to all beans --> <property name="customTargetSourceCreators"> <list> <bean class="org.springframework.aop.framework.autoproxy.target.LazyInitTargetSourceCreator" /> </list> </property> </bean> <bean id="myLazyInitBean" class="mypackage.MyBeanClass" lazy-init="true"> <!-- ... --> </bean>
- Juergen Hoeller, Sam Brannen
- See Also:
Method SummaryModifier and TypeMethodDescription
protected AbstractBeanFactoryBasedTargetSourceSubclasses must implement this method to return a new AbstractPrototypeBasedTargetSource if they wish to create a custom TargetSource for this bean, or
nullif they are not interested it in, in which case no special target source will be created.
protected booleanReturn whether this TargetSourceCreator is prototype-based.
Methods inherited from class org.springframework.aop.framework.autoproxy.target.AbstractBeanFactoryBasedTargetSourceCreator
buildInternalBeanFactory, destroy, getBeanFactory, getInternalBeanFactoryForBean, getTargetSource, setBeanFactory
isPrototypeBasedprotected boolean isPrototypeBased()Description copied from class:
AbstractBeanFactoryBasedTargetSourceCreatorReturn whether this TargetSourceCreator is prototype-based. The scope of the target bean definition will be set accordingly.
Default is "true".
createBeanFactoryBasedTargetSource@Nullable protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource
(Class<?> beanClass, String beanName)Description copied from class:
AbstractBeanFactoryBasedTargetSourceCreatorSubclasses must implement this method to return a new AbstractPrototypeBasedTargetSource if they wish to create a custom TargetSource for this bean, or
nullif they are not interested it in, in which case no special target source will be created. Subclasses should not call
setBeanFactoryon the AbstractPrototypeBasedTargetSource: This class' implementation of
getTargetSource()will do that.