类 AbstractBeanFactoryBasedTargetSourceCreator
- java.lang.Object
- org.springframework.aop.framework.autoproxy.target.AbstractBeanFactoryBasedTargetSourceCreator
- 所有已实现的接口:
TargetSourceCreator
,Aware
,BeanFactoryAware
,DisposableBean
public abstract class AbstractBeanFactoryBasedTargetSourceCreator extends Object implements TargetSourceCreator, BeanFactoryAware, DisposableBean
Convenient superclass forTargetSourceCreator
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
.- 作者:
- Rod Johnson, Juergen Hoeller
- 另请参阅:
AbstractBeanFactoryBasedTargetSource
,AbstractBeanFactory
构造器概要
构造器 构造器 说明 AbstractBeanFactoryBasedTargetSourceCreator()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected DefaultListableBeanFactory
buildInternalBeanFactory(ConfigurableBeanFactory containingFactory)
Build an internal BeanFactory for resolving target beans.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, ornull
if they are not interested it in, in which case no special target source will be created.void
destroy()
Destroys the internal BeanFactory on shutdown of the TargetSourceCreator.protected BeanFactory
getBeanFactory()
Return the BeanFactory that this TargetSourceCreators runs in.protected DefaultListableBeanFactory
getInternalBeanFactoryForBean(String beanName)
Return the internal BeanFactory to be used for the specified bean.TargetSource
getTargetSource(Class<?> beanClass, String beanName)
Create a special TargetSource for the given bean, if any.protected boolean
isPrototypeBased()
Return whether this TargetSourceCreator is prototype-based.void
setBeanFactory(BeanFactory beanFactory)
Callback that supplies the owning factory to a bean instance.
构造器详细资料
AbstractBeanFactoryBasedTargetSourceCreator
public AbstractBeanFactoryBasedTargetSourceCreator()
方法详细资料
setBeanFactory
public final void setBeanFactory(BeanFactory beanFactory)
从接口复制的说明:BeanFactoryAware
Callback 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.- 指定者:
setBeanFactory
在接口中BeanFactoryAware
- 参数:
beanFactory
- owning BeanFactory (nevernull
). The bean can immediately call methods on the factory.- 另请参阅:
BeanInitializationException
getBeanFactory
protected final 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 forbeanName
- the name of the bean- 返回:
- a special TargetSource or
null
if this TargetSourceCreator isn't interested in the particular bean
getInternalBeanFactoryForBean
protected DefaultListableBeanFactory 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 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
destroy
public void destroy()
Destroys the internal BeanFactory on shutdown of the TargetSourceCreator.
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".
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, ornull
if they are not interested it in, in which case no special target source will be created. Subclasses should not callsetTargetBeanName
orsetBeanFactory
on the AbstractPrototypeBasedTargetSource: This class' implementation ofgetTargetSource()
will do that.- 参数:
beanClass
- the class of the bean to create a TargetSource forbeanName
- the name of the bean- 返回:
- the AbstractPrototypeBasedTargetSource, or
null
if we don't match this