public abstract class

AbstractBeanFactoryBasedTargetSource

extends Object
implements Serializable TargetSource BeanFactoryAware
java.lang.Object
   ↳ org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

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.

Summary

Fields
protected final Log logger Logger available to subclasses
Public Constructors
AbstractBeanFactoryBasedTargetSource()
Public Methods
boolean equals(Object other)
BeanFactory getBeanFactory()
Return the owning BeanFactory.
String getTargetBeanName()
Return the name of the target bean in the factory.
synchronized Class<?> getTargetClass()
Return the type of targets returned by this TargetSource.
int hashCode()
boolean isStatic()
Will all calls to getTarget() return the same object?

In that case, there will be no need to invoke releaseTarget(Object), and the AOP framework can cache the return value of getTarget().

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.
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 Methods
void copyFrom(AbstractBeanFactoryBasedTargetSource other)
Copy configuration from the other AbstractBeanFactoryBasedTargetSource object.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.aop.TargetClassAware
From interface org.springframework.aop.TargetSource
From interface org.springframework.beans.factory.BeanFactoryAware

Fields

protected final Log logger

Logger available to subclasses

Public Constructors

public AbstractBeanFactoryBasedTargetSource ()

Public Methods

public boolean equals (Object other)

public BeanFactory getBeanFactory ()

Return the owning BeanFactory.

public String getTargetBeanName ()

Return the name of the target bean in the factory.

public synchronized Class<?> getTargetClass ()

Return the type of targets returned by this TargetSource.

Can return null, although certain usages of a TargetSource might just work with a predetermined target class.

Returns

public int hashCode ()

public boolean isStatic ()

Will all calls to getTarget() return the same object?

In that case, there will be no need to invoke releaseTarget(Object), and the AOP framework can cache the return value of getTarget().

Returns
  • true if the target is immutable

public void releaseTarget (Object target)

Release the given target object obtained from the getTarget() method.

Parameters
target object obtained from a call to getTarget()
Throws
Exception

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.

public void setTargetBeanName (String targetBeanName)

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

public 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).

Default is to detect the type automatically, through a getType call on the BeanFactory (or even a full getBean call as fallback).

public String toString ()

Protected Methods

protected void copyFrom (AbstractBeanFactoryBasedTargetSource other)

Copy configuration from the other AbstractBeanFactoryBasedTargetSource object. Subclasses should override this if they wish to expose it.

Parameters
other object to copy configuration from