org.springframework.aop.target

## 类 ThreadLocalTargetSource

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

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

      public class ThreadLocalTargetSource
      extends AbstractPrototypeBasedTargetSource
      implements ThreadLocalTargetSourceStats, org.springframework.beans.factory.DisposableBean

  Alternative to an object pool. This `TargetSource` uses a threading model in which every thread has its own copy of the target. There's no contention for targets. Target object creation is kept to a minimum on the running server.

  Application code is written as to a normal pool; callers can't assume they will be dealing with the same instance in invocations in different threads. However, state can be relied on during the operations of a single thread: for example, if one caller makes repeated calls on the AOP proxy.

  Cleanup of thread-bound objects is performed on BeanFactory destruction, calling their `DisposableBean.destroy()` method if available. Be aware that many thread-bound objects can be around until the application actually shuts down.

  作者:
    Rod Johnson, Juergen Hoeller, Rob Harrop
  另请参阅:
    `ThreadLocalTargetSourceStats`, `DisposableBean.destroy()`, 序列化表格

- - ### 字段概要

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

      `logger`

  - ### 构造器概要

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

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `destroy()` Dispose of targets if necessary; clear ThreadLocal.
    `int` | `getHitCount()` Return the number of hits that were satisfied by a thread-bound object.
    `int` | `getInvocationCount()` Return the number of client invocations.
    `int` | `getObjectCount()` Return the number of thread-bound objects created.
    `IntroductionAdvisor` | `getStatsMixin()` Return an introduction advisor mixin that allows the AOP proxy to be cast to ThreadLocalInvokerStats.
    `Object` | `getTarget()` Implementation of abstract getTarget() method.

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

      `destroyPrototypeInstance, newPrototypeInstance, setBeanFactory, writeReplace`

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

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

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

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

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

    - #### ThreadLocalTargetSource

          public ThreadLocalTargetSource()

  - ### 方法详细资料

    - #### getTarget

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

      Implementation of abstract getTarget() method. We look for a target held in a ThreadLocal. If we don't find one, we create one and bind it to the thread. No synchronization is required.
      指定者:
        `getTarget` 在接口中 `TargetSource`
      返回:
        the target object which contains the joinpoint, or `null` if there is no actual target instance
      抛出:
        `org.springframework.beans.BeansException`

    - #### destroy

          public void destroy()

      Dispose of targets if necessary; clear ThreadLocal.
      指定者:
        `destroy` 在接口中 `org.springframework.beans.factory.DisposableBean`
      另请参阅:
        `AbstractPrototypeBasedTargetSource.destroyPrototypeInstance(java.lang.Object)`

    - #### getInvocationCount

          public int getInvocationCount()

      从接口复制的说明: `ThreadLocalTargetSourceStats`
      Return the number of client invocations.
      指定者:
        `getInvocationCount` 在接口中 `ThreadLocalTargetSourceStats`

    - #### getHitCount

          public int getHitCount()

      从接口复制的说明: `ThreadLocalTargetSourceStats`
      Return the number of hits that were satisfied by a thread-bound object.
      指定者:
        `getHitCount` 在接口中 `ThreadLocalTargetSourceStats`

    - #### getObjectCount

          public int getObjectCount()

      从接口复制的说明: `ThreadLocalTargetSourceStats`
      Return the number of thread-bound objects created.
      指定者:
        `getObjectCount` 在接口中 `ThreadLocalTargetSourceStats`

    - #### getStatsMixin

          public IntroductionAdvisor getStatsMixin()

      Return an introduction advisor mixin that allows the AOP proxy to be cast to ThreadLocalInvokerStats.