Top Description Fields Constructors Methods
org.dom4j.util

public Class PerThreadSingleton<T>

extends Object
implements SingletonStrategy<T>
Class Inheritance
All Implemented Interfaces
org.dom4j.util.SingletonStrategy
Imports
java.lang.ref.WeakReference

PerThreadSingleton is an implementation of the SingletonStrategy used to provide common factory access to a single object instance based on an implementation strategy for one object instance per thread. This is useful in replace of the ThreadLocal usage.

Author
David Lucas
Version
$Revision: 1.3 $

Field Summary

Modifier and TypeField and Description
private ThreadLocal<WeakReference<T>>
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public T
public void
reset()

Implements org.dom4j.util.SingletonStrategy.reset.

reset the instance to a new instance for the implemented strategy
public void
setSingletonClassName(String
DOCUMENT ME!
singletonClassName
)

Implements org.dom4j.util.SingletonStrategy.setSingletonClassName.

set a singleton class name that will be used to create the singleton based on the strategy implementation of this interface.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

perThreadCacheback to summary
private ThreadLocal<WeakReference<T>> perThreadCache
singletonClassNameback to summary
private String singletonClassName

Constructor Detail

PerThreadSingletonback to summary
public PerThreadSingleton()

Method Detail

instanceback to summary
public T instance()

Implements org.dom4j.util.SingletonStrategy.instance.

Returns:T

Doc from org.dom4j.util.SingletonStrategy.instance.

a singleton instance of the class specified in setSingletonClass

resetback to summary
public void reset()

Implements org.dom4j.util.SingletonStrategy.reset.

Doc from org.dom4j.util.SingletonStrategy.reset.

reset the instance to a new instance for the implemented strategy

setSingletonClassNameback to summary
public void setSingletonClassName(String singletonClassName)

Implements org.dom4j.util.SingletonStrategy.setSingletonClassName.

Doc from org.dom4j.util.SingletonStrategy.setSingletonClassName.

set a singleton class name that will be used to create the singleton based on the strategy implementation of this interface. The default constructor of the class will be used and must be public.

Parameters
singletonClassName:String

DOCUMENT ME!