org.springframework.aop.target

## 类 AbstractLazyCreationTargetSource

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

- 所有已实现的接口:
    TargetClassAware, TargetSource

      public abstract class AbstractLazyCreationTargetSource
      extends Object
      implements TargetSource

  `TargetSource` implementation that will lazily create a user-managed object.

  Creation of the lazy target object is controlled by the user by implementing the `createObject()` method. This `TargetSource` will invoke this method the first time the proxy is accessed.

  Useful when you need to pass a reference to some dependency to an object but you don't actually want the dependency to be created until it is first used. A typical scenario for this is a connection to a remote resource.

  从以下版本开始:
    1.2.4
  作者:
    Rob Harrop, Juergen Hoeller
  另请参阅:
    `isInitialized()`, `createObject()`

- - ### 字段概要

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

  - ### 构造器概要

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

  - ### 方法概要

    所有方法 实例方法 抽象方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected abstract Object` | `createObject()` Subclasses should implement this method to return the lazy initialized object.
    `Object` | `getTarget()` Returns the lazy-initialized target object, creating it on-the-fly if it doesn't exist already.
    `Class<?>` | `getTargetClass()` This default implementation returns `null` if the target is `null` (it is hasn't yet been initialized), or the target class if the target has already been initialized.
    `boolean` | `isInitialized()` Return whether the lazy target object of this TargetSource has already been fetched.
    `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.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 字段详细资料

    - #### logger

          protected final Log logger

      Logger available to subclasses

  - ### 构造器详细资料

    - #### AbstractLazyCreationTargetSource

          public AbstractLazyCreationTargetSource()

  - ### 方法详细资料

    - #### isInitialized

          public boolean isInitialized()

      Return whether the lazy target object of this TargetSource has already been fetched.

    - #### getTargetClass

          @Nullable
          public Class<?> getTargetClass()

      This default implementation returns `null` if the target is `null` (it is hasn't yet been initialized), or the target class if the target has already been initialized.

      Subclasses may wish to override this method in order to provide a meaningful value when the target is still `null`.

      指定者:
        `getTargetClass` 在接口中 `TargetClassAware`
      指定者:
        `getTargetClass` 在接口中 `TargetSource`
      返回:
        the type of targets returned by this `TargetSource`
      另请参阅:
        `isInitialized()`

    - #### 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()`

    - #### getTarget

          public Object getTarget()
                           throws Exception

      Returns the lazy-initialized target object, creating it on-the-fly if it doesn't exist already.
      指定者:
        `getTarget` 在接口中 `TargetSource`
      返回:
        the target object which contains the joinpoint, or `null` if there is no actual target instance
      抛出:
        `Exception` - if the target object can't be resolved
      另请参阅:
        `createObject()`

    - #### 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

    - #### createObject

          protected abstract Object createObject()
                                          throws Exception

      Subclasses should implement this method to return the lazy initialized object. Called the first time the proxy is invoked.
      返回:
        the created object
      抛出:
        `Exception` - if creation failed