Package org.jboss.util.collection
Class WeakTypeCache<T>
- java.lang.Object
-
- org.jboss.util.collection.WeakTypeCache<T>
-
- Type Parameters:
T- the cached type
public abstract class WeakTypeCache<T> extends java.lang.ObjectA 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 WeakTypeCache()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidgenerate(java.lang.Class<?> clazz, T result)Fill in the resultprotected abstract voidgenerate(java.lang.reflect.ParameterizedType type, T result)Fill in the resultTget(java.lang.reflect.Type type)Get the information for a typeTget(java.lang.String name, java.lang.ClassLoader cl)Get the information for a classprotected TgetClass(java.lang.Class<?> clazz)Get the information for a classprotected java.util.Map<java.lang.String,T>getClassLoaderCache(java.lang.ClassLoader cl)Get the cache for the classloaderprotected TgetGenericArrayType(java.lang.reflect.GenericArrayType type)Get the information for an array typeprotected TgetParameterizedType(java.lang.reflect.ParameterizedType type)Get the information for a parameterized typeprotected <D extends java.lang.reflect.GenericDeclaration>
TgetTypeVariable(java.lang.reflect.TypeVariable<D> type)Get the information for a type variableprotected TgetWildcardType(java.lang.reflect.WildcardType type)Get the information for a wildcard typeprotected abstract Tinstantiate(java.lang.Class<?> clazz)Instantiate for a classprotected abstract Tinstantiate(java.lang.reflect.ParameterizedType type)Instantiate for a parameterized typeprotected Tpeek(java.lang.Class<?> clazz)Peek into the cacheprotected Tpeek(java.lang.reflect.ParameterizedType type)Peek into the cacheprotected voidput(java.lang.Class<?> clazz, T result)Put a result into the cacheprotected voidput(java.lang.reflect.ParameterizedType type, T result)Put a result into the cache
-
-
-
Field Detail
-
cache
private java.util.Map<java.lang.ClassLoader,java.util.Map<java.lang.String,T>> cache
The cache
-
-
Method Detail
-
get
public T get(java.lang.reflect.Type type)
Get the information for a type- Parameters:
type- the type- 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
-
instantiate
protected abstract T instantiate(java.lang.reflect.ParameterizedType type)
Instantiate for a parameterized type- Parameters:
type- the parameterized type- Returns:
- the result
-
generate
protected abstract void generate(java.lang.reflect.ParameterizedType type, T result)Fill in the result- Parameters:
type- the parameterized typeresult- the result
-
getParameterizedType
protected T getParameterizedType(java.lang.reflect.ParameterizedType type)
Get the information for a parameterized type- Parameters:
type- the parameterized type- Returns:
- the info
-
getWildcardType
protected T getWildcardType(java.lang.reflect.WildcardType type)
Get the information for a wildcard type- Parameters:
type- the paremeterized type- Returns:
- the info
-
getTypeVariable
protected <D extends java.lang.reflect.GenericDeclaration> T getTypeVariable(java.lang.reflect.TypeVariable<D> type)
Get the information for a type variable- Type Parameters:
D- the declaration- Parameters:
type- the type variable- Returns:
- the info
-
getGenericArrayType
protected T getGenericArrayType(java.lang.reflect.GenericArrayType type)
Get the information for an array type- Parameters:
type- the array type- Returns:
- the info
-
peek
protected T peek(java.lang.reflect.ParameterizedType type)
Peek into the cache- Parameters:
type- the type- Returns:
- the value
-
put
protected void put(java.lang.reflect.ParameterizedType type, T result)Put a result into the cache- Parameters:
type- the typeresult- the value
-
getClass
protected T getClass(java.lang.Class<?> clazz)
Get the information for a class- Parameters:
clazz- the class- Returns:
- the info
-
peek
protected T peek(java.lang.Class<?> clazz)
Peek into the cache- Parameters:
clazz- the class- Returns:
- the value
-
put
protected void put(java.lang.Class<?> clazz, T result)Put a result into the cache- Parameters:
clazz- the classresult- the value
-
getClassLoaderCache
protected java.util.Map<java.lang.String,T> getClassLoaderCache(java.lang.ClassLoader cl)
Get the cache for the classloader- Parameters:
cl- the classloader- Returns:
- the map
-
-