程序包 infra.aop.target
类 ThreadLocalTargetSource
java.lang.Object
infra.aop.target.AbstractBeanFactoryTargetSource
infra.aop.target.AbstractPrototypeTargetSource
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
- 另请参阅:
-
ThreadLocalTargetSourceStatsDisposableBean.destroy()- 序列化表格
-
字段概要
字段修饰符和类型字段说明private intprivate intprivate static final longprivate final ThreadLocal<Object>ThreadLocal holding the target associated with the current thread.Set of managed targets, enabling us to keep track of the targets we've created.从类继承的字段 infra.aop.target.AbstractBeanFactoryTargetSource
logger -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voiddestroy()Dispose of targets if necessary; clear ThreadLocal.intReturn the number of hits that were satisfied by a thread-bound object.intReturn the number of client invocations.intReturn the number of thread-bound objects created.Return an introduction advisor mixin that allows the AOP proxy to be cast to ThreadLocalInvokerStats.Implementation of abstract getTarget() method.从类继承的方法 infra.aop.target.AbstractPrototypeTargetSource
destroyPrototypeInstance, newPrototypeInstance, setBeanFactory, writeReplace从类继承的方法 infra.aop.target.AbstractBeanFactoryTargetSource
copyFrom, equals, getBeanFactory, getTargetBeanName, getTargetClass, hashCode, isStatic, releaseTarget, setTargetBeanName, setTargetClass, toString
-
字段详细资料
-
serialVersionUID
private static final long serialVersionUID- 另请参阅:
-
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
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()
-
-
方法详细资料
-
getTarget
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 join-point,
or
nullif there is no actual target instance
-
destroy
public void destroy()Dispose of targets if necessary; clear ThreadLocal.- 指定者:
destroy在接口中infra.beans.factory.DisposableBean- 另请参阅:
-
getInvocationCount
public int getInvocationCount()从接口复制的说明:ThreadLocalTargetSourceStatsReturn the number of client invocations. -
getHitCount
public int getHitCount()从接口复制的说明:ThreadLocalTargetSourceStatsReturn the number of hits that were satisfied by a thread-bound object.- 指定者:
getHitCount在接口中ThreadLocalTargetSourceStats
-
getObjectCount
public int getObjectCount()从接口复制的说明:ThreadLocalTargetSourceStatsReturn the number of thread-bound objects created.- 指定者:
getObjectCount在接口中ThreadLocalTargetSourceStats
-
getStatsMixin
Return an introduction advisor mixin that allows the AOP proxy to be cast to ThreadLocalInvokerStats.
-