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 SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidCopy configuration from the other AbstractBeanFactoryBasedTargetSource object.booleanReturn the owning BeanFactory.Return the name of the target bean in the factory.Class<?>Return the type of targets returned by thisTargetSource.inthashCode()booleanisStatic()Will all calls toTargetSource.getTarget()return the same object?voidreleaseTarget(Object target) Release the given target object obtained from theTargetSource.getTarget()method, if any.voidsetBeanFactory(BeanFactory beanFactory) Set the owning BeanFactory.voidsetTargetBeanName(String targetBeanName) Set the name of the target bean in the factory.voidsetTargetClass(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.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.aop.TargetSourcegetTarget
- 
Field Details- 
loggerLogger available to subclasses.
 
- 
- 
Constructor Details- 
AbstractBeanFactoryBasedTargetSourcepublic AbstractBeanFactoryBasedTargetSource()
 
- 
- 
Method Details- 
setTargetBeanNameSet 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:
 
- 
getTargetBeanNameReturn the name of the target bean in the factory.
- 
setTargetClassSpecify 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 getTypecall on the BeanFactory (or even a fullgetBeancall as fallback).
- 
setBeanFactorySet the owning BeanFactory. We need to save a reference so that we can use thegetBeanmethod on every invocation.- Specified by:
- setBeanFactoryin interface- BeanFactoryAware
- Parameters:
- beanFactory- owning BeanFactory (never- null). The bean can immediately call methods on the factory.
- See Also:
 
- 
getBeanFactoryReturn the owning BeanFactory.
- 
getTargetClassDescription copied from interface:TargetSourceReturn the type of targets returned by thisTargetSource.Can return null, although certain usages of aTargetSourcemight just work with a predetermined target class.- Specified by:
- getTargetClassin interface- TargetClassAware
- Specified by:
- getTargetClassin interface- TargetSource
- Returns:
- the type of targets returned by this TargetSource
 
- 
isStaticpublic boolean isStatic()Description copied from interface:TargetSourceWill all calls toTargetSource.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 ofTargetSource.getTarget().- Specified by:
- isStaticin interface- TargetSource
- Returns:
- trueif the target is immutable
- See Also:
 
- 
releaseTargetDescription copied from interface:TargetSourceRelease the given target object obtained from theTargetSource.getTarget()method, if any.- Specified by:
- releaseTargetin interface- TargetSource
- Parameters:
- target- object obtained from a call to- TargetSource.getTarget()
- Throws:
- Exception- if the object can't be released
 
- 
copyFromCopy configuration from the other AbstractBeanFactoryBasedTargetSource object. Subclasses should override this if they wish to expose it.- Parameters:
- other- object to copy configuration from
 
- 
equals
- 
hashCodepublic int hashCode()
- 
toString
 
-