public class

ThreadLocalTargetSource

extends AbstractPrototypeBasedTargetSource
implements ThreadLocalTargetSourceStats DisposableBean
java.lang.Object
   ↳ org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
     ↳ org.springframework.aop.target.AbstractPrototypeBasedTargetSource
       ↳ org.springframework.aop.target.ThreadLocalTargetSource

Class Overview

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.

Summary

[Expand]
Inherited Fields
From class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
Public Constructors
ThreadLocalTargetSource()
Public Methods
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.
[Expand]
Inherited Methods
From class org.springframework.aop.target.AbstractPrototypeBasedTargetSource
From class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
From class java.lang.Object
From interface org.springframework.aop.TargetClassAware
From interface org.springframework.aop.TargetSource
From interface org.springframework.aop.target.ThreadLocalTargetSourceStats
From interface org.springframework.beans.factory.BeanFactoryAware
From interface org.springframework.beans.factory.DisposableBean

Public Constructors

public ThreadLocalTargetSource ()

Public Methods

public void destroy ()

Dispose of targets if necessary; clear ThreadLocal.

public int getHitCount ()

Return the number of hits that were satisfied by a thread-bound object.

public int getInvocationCount ()

Return the number of client invocations.

public int getObjectCount ()

Return the number of thread-bound objects created.

public IntroductionAdvisor getStatsMixin ()

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

public Object 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.