程序包 infra.aop.target

类 ThreadLocalTargetSource

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

public class ThreadLocalTargetSource extends AbstractPrototypeTargetSource implements ThreadLocalTargetSourceStats, infra.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.

从以下版本开始:
3.0
作者:
Rod Johnson, Juergen Hoeller, Rob Harrop, TODAY 2021/2/1 20:41
另请参阅:
  • 字段详细资料

    • serialVersionUID

      private static final long serialVersionUID
      另请参阅:
    • targetInThread

      private final ThreadLocal<Object> targetInThread
      ThreadLocal holding the target associated with the current thread. Unlike most ThreadLocals, which are static, this variable is meant to be per thread per instance of the ThreadLocalTargetSource class.
    • targetSet

      private final Set<Object> targetSet
      Set of managed targets, enabling us to keep track of the targets we've created.
    • invocationCount

      private int invocationCount
    • hitCount

      private int hitCount
  • 构造器详细资料

    • ThreadLocalTargetSource

      public ThreadLocalTargetSource()
  • 方法详细资料