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
Method SummaryModifier and TypeMethodDescription
protected DefaultListableBeanFactoryBuild an internal BeanFactory for resolving target beans.
protected abstract 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.
destroy()Destroys the internal BeanFactory on shutdown of the TargetSourceCreator.
protected final BeanFactoryReturn the BeanFactory that this TargetSourceCreators runs in.
protected DefaultListableBeanFactoryReturn the internal BeanFactory to be used for the specified bean.
final TargetSourceCreate a special TargetSource for the given bean, if any.
protected booleanReturn whether this TargetSourceCreator is prototype-based.
final voidCallback that supplies the owning factory to a bean instance.
loggerprotected final Log logger
setBeanFactorypublic final void setBeanFactory
(BeanFactory beanFactory)Description copied from interface:
BeanFactoryAwareCallback that supplies the owning factory to a bean instance.
Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean.afterPropertiesSet()or a custom init-method.
getBeanFactoryprotected final BeanFactory getBeanFactory()Return the BeanFactory that this TargetSourceCreators runs in.
getTargetSourceDescription copied from interface:
TargetSourceCreatorCreate a special TargetSource for the given bean, if any.
getInternalBeanFactoryForBeanReturn the internal BeanFactory to be used for the specified bean.
beanName- the name of the target bean
- the internal BeanFactory to be used
buildInternalBeanFactoryprotected DefaultListableBeanFactory buildInternalBeanFactory
(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
destroypublic void destroy()Destroys the internal BeanFactory on shutdown of the TargetSourceCreator.
isPrototypeBasedprotected boolean isPrototypeBased()Return whether this TargetSourceCreator is prototype-based. The scope of the target bean definition will be set accordingly.
Default is "true".
- See Also:
createBeanFactoryBasedTargetSource@Nullable protected abstract 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
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.
beanClass- the class of the bean to create a TargetSource for
beanName- the name of the bean
- the AbstractPrototypeBasedTargetSource, or
nullif we don't match this