Class AbstractBeanFactoryBasedTargetSource
- All Implemented Interfaces:
Serializable
,TargetClassAware
,TargetSource
,Aware
,BeanFactoryAware
- Direct Known Subclasses:
AbstractPrototypeBasedTargetSource
,LazyInitTargetSource
,SimpleBeanTargetSource
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
.
- Since:
- 1.1.4
- Author:
- Juergen Hoeller, Rod Johnson
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Copy configuration from the other AbstractBeanFactoryBasedTargetSource object.boolean
Return the owning BeanFactory.Return the name of the target bean in the factory.Class<?>
Return the type of targets returned by thisTargetSource
.int
hashCode()
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).toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.aop.TargetSource
getTarget, isStatic, releaseTarget
-
Field Details
-
logger
Logger available to subclasses.
-
-
Constructor Details
-
AbstractBeanFactoryBasedTargetSource
public AbstractBeanFactoryBasedTargetSource()
-
-
Method Details
-
setTargetBeanName
Set the name of the target bean in the factory.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
.- Parameters:
targetBeanName
- name of the target bean in the BeanFactory that owns this interceptor- See Also:
-
getTargetBeanName
Return the name of the target bean in the factory. -
setTargetClass
Specify the target class explicitly, to avoid any kind of access to the target bean (for example, to avoid initialization of a FactoryBean instance).Default is to detect the type automatically, through a
getType
call on the BeanFactory (or even a fullgetBean
call as fallback). -
setBeanFactory
Set the owning BeanFactory. We need to save a reference so that we can use thegetBean
method on every invocation.- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Parameters:
beanFactory
- owning BeanFactory (nevernull
). The bean can immediately call methods on the factory.- See Also:
-
getBeanFactory
Return the owning BeanFactory. -
getTargetClass
Description copied from interface:TargetSource
Return the type of targets returned by thisTargetSource
.Can return
null
, although certain usages of aTargetSource
might just work with a predetermined target class.- Specified by:
getTargetClass
in interfaceTargetClassAware
- Specified by:
getTargetClass
in interfaceTargetSource
- Returns:
- the type of targets returned by this
TargetSource
-
copyFrom
Copy configuration from the other AbstractBeanFactoryBasedTargetSource object. Subclasses should override this if they wish to expose it.- Parameters:
other
- object to copy configuration from
-
equals
-
hashCode
public int hashCode() -
toString
-