|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
public abstract class AbstractBeanFactoryBasedTargetSource
Base class for TargetSource implementations
that are based on a Spring BeanFactory,
delegating to Spring-managed bean instances.
Subclasses can create prototype instances or lazily access a
singleton target, for example. See LazyInitTargetSource and
AbstractPrototypeBasedTargetSource's subclasses for concrete strategies.
BeanFactory-based TargetSources are serializable. This involves
disconnecting the current target and turning into a SingletonTargetSource.
BeanFactory.getBean(java.lang.String),
LazyInitTargetSource,
PrototypeTargetSource,
ThreadLocalTargetSource,
CommonsPoolTargetSource,
Serialized Form| Field Summary | |
|---|---|
protected Log |
logger
Logger available to subclasses |
| Constructor Summary | |
|---|---|
AbstractBeanFactoryBasedTargetSource()
|
|
| Method Summary | |
|---|---|
protected void |
copyFrom(AbstractBeanFactoryBasedTargetSource other)
Copy configuration from the other AbstractBeanFactoryBasedTargetSource object. |
boolean |
equals(Object other)
|
BeanFactory |
getBeanFactory()
Return the owning BeanFactory. |
String |
getTargetBeanName()
Return the name of the target bean in the factory. |
Class |
getTargetClass()
Return the type of targets returned by this TargetSource. |
int |
hashCode()
|
boolean |
isStatic()
Will all calls to TargetSource.getTarget() return the same object? |
void |
releaseTarget(Object target)
Release the given target object obtained from the TargetSource.getTarget() method. |
void |
setBeanFactory(BeanFactory beanFactory)
Set the owning BeanFactory. |
void |
setTargetBeanName(String targetBeanName)
Set the name of the target bean in the factory. |
void |
setTargetClass(Class targetClass)
Specify the target class explicitly, to avoid any kind of access to the target bean (for example, to avoid initialization of a FactoryBean instance). |
String |
toString()
|
protected Object |
writeReplace()
Replaces this object with a SingletonTargetSource on serialization. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.springframework.aop.TargetSource |
|---|
getTarget |
| Field Detail |
|---|
protected final Log logger
| Constructor Detail |
|---|
public AbstractBeanFactoryBasedTargetSource()
| Method Detail |
|---|
public void setTargetBeanName(String targetBeanName)
The target bean should not be a singleton, else the same instance will
always be obtained from the factory, resulting in the same behavior as
provided by SingletonTargetSource.
targetBeanName - name of the target bean in the BeanFactory
that owns this interceptorSingletonTargetSourcepublic String getTargetBeanName()
public void setTargetClass(Class targetClass)
Default is to detect the type automatically, through a getType
call on the BeanFactory (or even a full getBean call as fallback).
public void setBeanFactory(BeanFactory beanFactory)
throws BeansException
getBean method on every invocation.
setBeanFactory in interface BeanFactoryAwarebeanFactory - owning BeanFactory (never null).
The bean can immediately call methods on the factory.
BeansException - in case of initialization errorsBeanInitializationExceptionpublic BeanFactory getBeanFactory()
public Class getTargetClass()
TargetSourceTargetSource.
Can return null, although certain usages of a
TargetSource might just work with a predetermined
target class.
getTargetClass in interface TargetClassAwaregetTargetClass in interface TargetSourceTargetSourcepublic boolean isStatic()
TargetSourceTargetSource.getTarget() return the same object?
In that case, there will be no need to invoke
TargetSource.releaseTarget(Object), and the AOP framework can cache
the return value of TargetSource.getTarget().
isStatic in interface TargetSourcetrue if the target is immutableTargetSource.getTarget()
public void releaseTarget(Object target)
throws Exception
TargetSourceTargetSource.getTarget() method.
releaseTarget in interface TargetSourcetarget - object obtained from a call to TargetSource.getTarget()
Exception - if the object can't be releasedprotected void copyFrom(AbstractBeanFactoryBasedTargetSource other)
other - object to copy configuration from
protected 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.
ObjectStreamExceptionpublic boolean equals(Object other)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||