org.apache.commons.beanutils
Class ContextClassLoaderLocal
java.lang.Object
org.apache.commons.beanutils.ContextClassLoaderLocal
public class ContextClassLoaderLocal
extends java.lang.Object
A value that is provided per (thread) context classloader.
Patterned after ThreadLocal.
There is a separate value used when Thread.getContextClassLoader() is null.
This mechanism provides isolation for web apps deployed in the same container.
Note: A WeakHashMap bug in several 1.3 JVMs results in a memory leak
for those JVMs.
java.lang.Thread.getContextClassLoader
Object | get() - Gets the instance which provides the functionality for
BeanUtils .
|
protected Object | initialValue() - Returns the initial value for this ContextClassLoaderLocal
variable.
|
void | set(Object value) - Sets the value - a value is provided per (thread) context classloader.
|
void | unset() - Unsets the value associated with the current thread's context classloader
|
void | unset(ClassLoader classLoader) - Unsets the value associated with the given classloader
|
globalValue
private Object globalValue
globalValueInitialized
private boolean globalValueInitialized
valueByClassLoader
private Map valueByClassLoader
ContextClassLoaderLocal
public ContextClassLoaderLocal()
get
public Object get()
Gets the instance which provides the functionality for
BeanUtils
.
This is a pseudo-singleton - an single instance is provided per (thread) context classloader.
This mechanism provides isolation for web apps deployed in the same container.
- the object currently associated with the
initialValue
protected Object initialValue()
Returns the initial value for this ContextClassLoaderLocal
variable. This method will be called once per Context ClassLoader for
each ContextClassLoaderLocal, the first time it is accessed
with get or set. If the programmer desires ContextClassLoaderLocal variables
to be initialized to some value other than null, ContextClassLoaderLocal must
be subclassed, and this method overridden. Typically, an anonymous
inner class will be used. Typical implementations of initialValue
will call an appropriate constructor and return the newly constructed
object.
- a new Object to be used as an initial value for this ContextClassLoaderLocal
set
public void set(Object value)
Sets the value - a value is provided per (thread) context classloader.
This mechanism provides isolation for web apps deployed in the same container.
value
- the object to be associated with the entrant thread's context classloader
unset
public void unset()
Unsets the value associated with the current thread's context classloader
unset
public void unset(ClassLoader classLoader)
Unsets the value associated with the given classloader
Copyright (c) 2001-2004 - Apache Software Foundation