|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.aop.target.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.
BeanFactoryBasedTargetSources are serializable. This involves disconnecting the current target and turning into a SingletonTargetSource.
BeanFactory.getBean(java.lang.String)
,
LazyInitTargetSource
,
PrototypeTargetSource
,
ThreadLocalTargetSource
,
CommonsPoolTargetSource
,
Serialized FormField Summary | |
protected Log |
logger
|
Constructor Summary | |
AbstractBeanFactoryBasedTargetSource()
|
Method Summary | |
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. |
boolean |
isStatic()
Will all calls to getTarget() return the same object?
|
void |
releaseTarget(Object target)
Release the given target object obtained from the getTarget() method. |
void |
setBeanFactory(BeanFactory beanFactory)
Set the owning BeanFactory. |
void |
setTargetBeanName(String targetBeanName)
Set the name of the target bean in the factory. |
protected Object |
writeReplace()
Replaces this object with a SingletonTargetSource on serialization. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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)
targetBeanName
- name of the target bean in the BeanFactory
that owns this interceptorSingletonTargetSource
public String getTargetBeanName()
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
getBean
method on every invocation.
setBeanFactory
in interface BeanFactoryAware
beanFactory
- owning BeanFactory (may not be null).
The bean can immediately call methods on the factory.
BeansException
- in case of initialization errorsBeanInitializationException
public BeanFactory getBeanFactory()
public Class getTargetClass()
TargetSource
getTargetClass
in interface TargetSource
public boolean isStatic()
TargetSource
getTarget()
return the same object?
In that case, there will be no need to invoke releaseTarget
,
and the AOP framework can cache the return value of getTarget()
.
isStatic
in interface TargetSource
TargetSource.getTarget()
public void releaseTarget(Object target) throws Exception
TargetSource
getTarget()
method.
releaseTarget
in interface TargetSource
target
- object obtained from a call to getTarget()
Exception
- if the object can't be releasedTargetSource.getTarget()
protected Object writeReplace() throws ObjectStreamException
With this implementation of this method, there is no need to mark non-serializable fields in this class or subclasses as transient.
ObjectStreamException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |