org.springframework.aop.target

## 类 AbstractBeanFactoryBasedTargetSource

- java.lang.Object
- - org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource

- 所有已实现的接口:
    Serializable, TargetClassAware, TargetSource, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware
  直接已知子类:
    AbstractPrototypeBasedTargetSource, LazyInitTargetSource, SimpleBeanTargetSource

      public abstract class AbstractBeanFactoryBasedTargetSource
      extends Object
      implements TargetSource, org.springframework.beans.factory.BeanFactoryAware, Serializable

  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`.

  从以下版本开始:
    1.1.4
  作者:
    Juergen Hoeller, Rod Johnson
  另请参阅:
    `BeanFactory.getBean(java.lang.String)`, `LazyInitTargetSource`, `PrototypeTargetSource`, `ThreadLocalTargetSource`, `CommonsPool2TargetSource`, 序列化表格

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `protected Log` | `logger` Logger available to subclasses

  - ### 构造器概要

    构造器
    构造器和说明
    `AbstractBeanFactoryBasedTargetSource()`

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected void` | `copyFrom(AbstractBeanFactoryBasedTargetSource other)` Copy configuration from the other AbstractBeanFactoryBasedTargetSource object.
    `boolean` | `equals(Object other)`
    `org.springframework.beans.factory.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, if any.
    `void` | `setBeanFactory(org.springframework.beans.factory.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()`

    - ### 从类继承的方法 java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### 从接口继承的方法 org.springframework.aop.TargetSource

      `getTarget`

- - ### 字段详细资料

    - #### logger

          protected final Log logger

      Logger available to subclasses

  - ### 构造器详细资料

    - #### AbstractBeanFactoryBasedTargetSource

          public AbstractBeanFactoryBasedTargetSource()

  - ### 方法详细资料

    - #### setTargetBeanName

          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`.

      参数:
        `targetBeanName` - name of the target bean in the BeanFactory that owns this interceptor
      另请参阅:
        `SingletonTargetSource`

    - #### getTargetBeanName

          public String getTargetBeanName()

      Return the name of the target bean in the factory.

    - #### setTargetClass

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

    - #### setBeanFactory

          public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)

      Set the owning BeanFactory. We need to save a reference so that we can use the `getBean` method on every invocation.
      指定者:
        `setBeanFactory` 在接口中 `org.springframework.beans.factory.BeanFactoryAware`

    - #### getBeanFactory

          public org.springframework.beans.factory.BeanFactory getBeanFactory()

      Return the owning BeanFactory.

    - #### getTargetClass

          public Class<?> getTargetClass()

      从接口复制的说明: `TargetSource`
      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.

      指定者:
        `getTargetClass` 在接口中 `TargetClassAware`
      指定者:
        `getTargetClass` 在接口中 `TargetSource`
      返回:
        the type of targets returned by this `TargetSource`

    - #### isStatic

          public boolean isStatic()

      从接口复制的说明: `TargetSource`
      Will all calls to `TargetSource.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` 在接口中 `TargetSource`
      返回:
        `true` if the target is immutable
      另请参阅:
        `TargetSource.getTarget()`

    - #### releaseTarget

          public void releaseTarget(Object target)
                             throws Exception

      从接口复制的说明: `TargetSource`
      Release the given target object obtained from the `TargetSource.getTarget()` method, if any.
      指定者:
        `releaseTarget` 在接口中 `TargetSource`
      参数:
        `target` - object obtained from a call to `TargetSource.getTarget()`
      抛出:
        `Exception` - if the object can't be released

    - #### copyFrom

          protected void copyFrom(AbstractBeanFactoryBasedTargetSource other)

      Copy configuration from the other AbstractBeanFactoryBasedTargetSource object. Subclasses should override this if they wish to expose it.
      参数:
        `other` - object to copy configuration from

    - #### equals

          public boolean equals(Object other)

      覆盖:
        `equals` 在类中 `Object`

    - #### hashCode

          public int hashCode()

      覆盖:
        `hashCode` 在类中 `Object`

    - #### toString

          public String toString()

      覆盖:
        `toString` 在类中 `Object`