org.springframework.aop.target

## 类 LazyInitTargetSource

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

- 所有已实现的接口:
    Serializable, TargetClassAware, TargetSource, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware

      public class LazyInitTargetSource
      extends AbstractBeanFactoryBasedTargetSource

  `TargetSource` that lazily accesses a singleton bean from a `BeanFactory`.

  Useful when a proxy reference is needed on initialization but the actual target object should not be initialized until first use. When the target bean is defined in an `org.springframework.context.ApplicationContext` (or a `BeanFactory` that is eagerly pre-instantiating singleton beans) it must be marked as "lazy-init" too, else it will be instantiated by said `ApplicationContext` (or `BeanFactory`) on startup.

  For example:

       <bean id="serviceTarget" class="example.MyService" lazy-init="true">
         ...
       </bean>

       <bean id="service" class="org.springframework.aop.framework.ProxyFactoryBean">
         <property name="targetSource">
           <bean class="org.springframework.aop.target.LazyInitTargetSource">
             <property name="targetBeanName"><idref local="serviceTarget"/></property>
           </bean>
         </property>
       </bean>

  The "serviceTarget" bean will not get initialized until a method on the "service" proxy gets invoked.

  Subclasses can extend this class and override the `postProcessTargetObject(Object)` to perform some additional processing with the target object when it is first loaded.

  从以下版本开始:
    1.1.4
  作者:
    Juergen Hoeller, Rob Harrop
  另请参阅:
    `BeanFactory.getBean(java.lang.String)`, `postProcessTargetObject(java.lang.Object)`, 序列化表格

- - ### 字段概要

    - ### 从类继承的字段 org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource

      `logger`

  - ### 构造器概要

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

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `Object` | `getTarget()` Return a target instance.
    `protected void` | `postProcessTargetObject(Object targetObject)` Subclasses may override this method to perform additional processing on the target object when it is first loaded.

    - ### 从类继承的方法 org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource

      `copyFrom, equals, getBeanFactory, getTargetBeanName, getTargetClass, hashCode, isStatic, releaseTarget, setBeanFactory, setTargetBeanName, setTargetClass, toString`

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

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

- - ### 构造器详细资料

    - #### LazyInitTargetSource

          public LazyInitTargetSource()

  - ### 方法详细资料

    - #### getTarget

          @Nullable
          public Object getTarget()
                                      throws org.springframework.beans.BeansException

      从接口复制的说明: `TargetSource`
      Return a target instance. Invoked immediately before the AOP framework calls the "target" of an AOP method invocation.
      返回:
        the target object which contains the joinpoint, or `null` if there is no actual target instance
      抛出:
        `org.springframework.beans.BeansException`

    - #### postProcessTargetObject

          protected void postProcessTargetObject(Object targetObject)

      Subclasses may override this method to perform additional processing on the target object when it is first loaded.
      参数:
        `targetObject` - the target object that has just been instantiated (and configured)