Package org.jboss.util.collection
Class WeakClassCache<T>
- java.lang.Object
-
- org.jboss.util.collection.WeakClassCache<T>
-
- Type Parameters:
T
- exact value type
public abstract class WeakClassCache<T> extends java.lang.Object
A weak class cache that instantiates does not a hold a strong reference to either the classloader or class.It creates the class specific data in two stages to avoid recursion.
instantiate - creates the data
generate - fills in the details
-
-
Constructor Summary
Constructors Constructor Description WeakClassCache()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
generate(java.lang.Class<?> clazz, T result)
Fill in the resultT
get(java.lang.Class<?> clazz)
Get the information for a classT
get(java.lang.String name, java.lang.ClassLoader cl)
Get the information for a classprotected java.util.Map<java.lang.String,java.lang.ref.WeakReference<T>>
getClassLoaderCache(java.lang.ClassLoader cl)
Get the cache for the classloaderprotected abstract T
instantiate(java.lang.Class<?> clazz)
Instantiate for a class
-
-
-
Field Detail
-
cache
protected final java.util.Map<java.lang.ClassLoader,java.util.Map<java.lang.String,java.lang.ref.WeakReference<T>>> cache
The cache
-
-
Method Detail
-
get
public T get(java.lang.Class<?> clazz)
Get the information for a class- Parameters:
clazz
- the class- Returns:
- the info
-
get
public T get(java.lang.String name, java.lang.ClassLoader cl) throws java.lang.ClassNotFoundException
Get the information for a class- Parameters:
name
- the namecl
- the classloader- Returns:
- the info
- Throws:
java.lang.ClassNotFoundException
- when the class cannot be found
-
instantiate
protected abstract T instantiate(java.lang.Class<?> clazz)
Instantiate for a class- Parameters:
clazz
- the class- Returns:
- the result
-
generate
protected abstract void generate(java.lang.Class<?> clazz, T result)
Fill in the result- Parameters:
clazz
- the classresult
- the result
-
getClassLoaderCache
protected java.util.Map<java.lang.String,java.lang.ref.WeakReference<T>> getClassLoaderCache(java.lang.ClassLoader cl)
Get the cache for the classloader- Parameters:
cl
- the classloader- Returns:
- the map
-
-