站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.0.5 API 文档英文版

AbstractBeanFactoryBasedTargetSourceCreator (Spring Framework API 2.0) - Spring Framework 2.0.5 API 文档英文版

The Spring Framework

org.springframework.aop.framework.autoproxy.target
Class AbstractBeanFactoryBasedTargetSourceCreator

java.lang.Object
  extended by org.springframework.aop.framework.autoproxy.target.AbstractBeanFactoryBasedTargetSourceCreator
All Implemented Interfaces:
TargetSourceCreator, BeanFactoryAware, DisposableBean
Direct Known Subclasses:
LazyInitTargetSourceCreator, QuickTargetSourceCreator

public abstract class AbstractBeanFactoryBasedTargetSourceCreator
extends Object
implements TargetSourceCreator, BeanFactoryAware, DisposableBean

Convenient superclass for TargetSourceCreator 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.

Author:
Rod Johnson, Juergen Hoeller
See Also:
AbstractBeanFactoryBasedTargetSource, AbstractBeanFactory

Field Summary
protected  Log logger
           
 
Constructor Summary
AbstractBeanFactoryBasedTargetSourceCreator()
           
 
Method Summary
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 null 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.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Constructor Detail

AbstractBeanFactoryBasedTargetSourceCreator

public AbstractBeanFactoryBasedTargetSourceCreator()
Method Detail

setBeanFactory

public final void setBeanFactory(BeanFactory beanFactory)
Description copied from interface: 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.

Specified by:
setBeanFactory in interface BeanFactoryAware
Parameters:
beanFactory - owning BeanFactory (never null). The bean can immediately call methods on the factory.
See Also:
BeanInitializationException

getBeanFactory

protected final BeanFactory getBeanFactory()
Return the BeanFactory that this TargetSourceCreators runs in.


destroy

public void destroy()
Destroys the internal BeanFactory on shutdown of the TargetSourceCreator.

Specified by:
destroy in interface DisposableBean

getTargetSource

public final TargetSource getTargetSource(Class beanClass,
                                          String beanName)
Description copied from interface: TargetSourceCreator
Create a special TargetSource for the given bean, if any.

Specified by:
getTargetSource in interface TargetSourceCreator
Parameters:
beanClass - the class of the bean to create a TargetSource for
beanName - the name of the bean
Returns:
a special TargetSource or null if this TargetSourceCreator isn't interested in the particular bean

isPrototypeBased

protected boolean isPrototypeBased()
Return whether this TargetSourceCreator is prototype-based. The "singleton" flag of the target bean definition will be set accordingly.

Default is "true".

See Also:
BeanDefinition.isSingleton()

createBeanFactoryBasedTargetSource

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

Parameters:
beanClass - the class of the bean to create a TargetSource for
beanName - the name of the bean
Returns:
the AbstractPrototypeBasedTargetSource, or null if we don't match this

The Spring Framework

Copyright © 2002-2007 The Spring Framework.