public abstract class AbstractPrototypeBasedTargetSource extends AbstractBeanFactoryBasedTargetSource
TargetSource implementations
that create new prototype bean instances to support a pooling or
new-instance-per-invocation strategy.
Such TargetSources must run in a BeanFactory, as it needs to
call the getBean method to create a new prototype instance.
Therefore, this base class extends AbstractBeanFactoryBasedTargetSource.
BeanFactory.getBean(java.lang.String),
PrototypeTargetSource,
ThreadLocalTargetSource,
CommonsPool2TargetSource,
Serialized Formlogger| Constructor and Description |
|---|
AbstractPrototypeBasedTargetSource() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
destroyPrototypeInstance(Object target)
Subclasses should call this method to destroy an obsolete prototype instance.
|
protected Object |
newPrototypeInstance()
Subclasses should call this method to create a new prototype instance.
|
void |
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
Set the owning BeanFactory.
|
protected Object |
writeReplace()
Replaces this object with a SingletonTargetSource on serialization.
|
copyFrom, equals, getBeanFactory, getTargetBeanName, getTargetClass, hashCode, isStatic, releaseTarget, setTargetBeanName, setTargetClass, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetTargetpublic void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
throws org.springframework.beans.BeansException
AbstractBeanFactoryBasedTargetSourcegetBean method on every invocation.setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAwaresetBeanFactory in class AbstractBeanFactoryBasedTargetSourceorg.springframework.beans.BeansExceptionprotected Object newPrototypeInstance() throws org.springframework.beans.BeansException
org.springframework.beans.BeansException - if bean creation failedprotected void destroyPrototypeInstance(Object target)
target - the bean instance to destroyprotected Object writeReplace() throws ObjectStreamException
writeReplace() method must be visible to the class
being serialized.)
With this implementation of this method, there is no need to mark non-serializable fields in this class or subclasses as transient.
ObjectStreamException