public abstract class

AbstractPrototypeBasedTargetSource

extends AbstractBeanFactoryBasedTargetSource
java.lang.Object
   ↳ org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
     ↳ org.springframework.aop.target.AbstractPrototypeBasedTargetSource
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Base class for dynamic 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.

Summary

[Expand]
Inherited Fields
From class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
Public Constructors
AbstractPrototypeBasedTargetSource()
Public Methods
void setBeanFactory(BeanFactory beanFactory)
Set the owning BeanFactory.
Protected Methods
void destroyPrototypeInstance(Object target)
Subclasses should call this method to destroy an obsolete prototype instance.
Object newPrototypeInstance()
Subclasses should call this method to create a new prototype instance.
Object writeReplace()
Replaces this object with a SingletonTargetSource on serialization.
[Expand]
Inherited Methods
From class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
From class java.lang.Object
From interface org.springframework.aop.TargetClassAware
From interface org.springframework.aop.TargetSource
From interface org.springframework.beans.factory.BeanFactoryAware

Public Constructors

public AbstractPrototypeBasedTargetSource ()

Public Methods

public void setBeanFactory (BeanFactory beanFactory)

Set the owning BeanFactory. We need to save a reference so that we can use the getBean method on every invocation.

Parameters
beanFactory owning BeanFactory (never null). The bean can immediately call methods on the factory.

Protected Methods

protected void destroyPrototypeInstance (Object target)

Subclasses should call this method to destroy an obsolete prototype instance.

Parameters
target the bean instance to destroy

protected Object newPrototypeInstance ()

Subclasses should call this method to create a new prototype instance.

Throws
BeansException if bean creation failed

protected Object writeReplace ()

Replaces this object with a SingletonTargetSource on serialization. Protected as otherwise it won't be invoked for subclasses. (The 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.