public class LazyInitTargetSourceCreator extends AbstractBeanFactoryBasedTargetSourceCreator
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 autodetected infrastructure bean in an XML application context definition:
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <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>
BeanDefinition.isLazyInit()
,
AbstractAutoProxyCreator.setCustomTargetSourceCreators(org.springframework.aop.framework.autoproxy.TargetSourceCreator...)
,
BeanNameAutoProxyCreator
logger
Constructor and Description |
---|
LazyInitTargetSourceCreator() |
Modifier and Type | Method and Description |
---|---|
protected AbstractBeanFactoryBasedTargetSource |
createBeanFactoryBasedTargetSource(Class<?> beanClass,
String beanName)
Subclasses must implement this method to return a new AbstractPrototypeBasedTargetSource
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. |
protected boolean |
isPrototypeBased()
Return whether this TargetSourceCreator is prototype-based.
|
buildInternalBeanFactory, destroy, getBeanFactory, getInternalBeanFactoryForBean, getTargetSource, setBeanFactory
protected boolean isPrototypeBased()
AbstractBeanFactoryBasedTargetSourceCreator
Default is "true".
isPrototypeBased
in class AbstractBeanFactoryBasedTargetSourceCreator
BeanDefinition.isSingleton()
protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(Class<?> beanClass, String beanName)
AbstractBeanFactoryBasedTargetSourceCreator
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 AbstractPrototypeBasedTargetSource: This class' implementation of
getTargetSource()
will do that.createBeanFactoryBasedTargetSource
in class AbstractBeanFactoryBasedTargetSourceCreator
beanClass
- the class of the bean to create a TargetSource forbeanName
- the name of the beannull
if we don't match this