JBoss Common Classes 2.2.17.GA

org.jboss.util.collection
Class WeakTypeCache<T>

java.lang.Object
  extended by org.jboss.util.collection.WeakTypeCache<T>
Type Parameters:
T - the cached type

public abstract class WeakTypeCache<T>
extends 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

Author:
Scott.Stark@jboss.org, Adrian Brock

Constructor Summary
WeakTypeCache()
           
 
Method Summary
protected abstract  void generate(Class<?> clazz, T result)
          Fill in the result
protected abstract  void generate(ParameterizedType type, T result)
          Fill in the result
 T get(String name, ClassLoader cl)
          Get the information for a class
 T get(Type type)
          Get the information for a type
protected  T getClass(Class<?> clazz)
          Get the information for a class
protected  Map<String,T> getClassLoaderCache(ClassLoader cl)
          Get the cache for the classloader
protected  T getGenericArrayType(GenericArrayType type)
          Get the information for an array type
protected  T getParameterizedType(ParameterizedType type)
          Get the information for a parameterized type
protected
<D extends GenericDeclaration>
T
getTypeVariable(TypeVariable<D> type)
          Get the information for a type variable
protected  T getWildcardType(WildcardType type)
          Get the information for a wildcard type
protected abstract  T instantiate(Class<?> clazz)
          Instantiate for a class
protected abstract  T instantiate(ParameterizedType type)
          Instantiate for a parameterized type
protected  T peek(Class<?> clazz)
          Peek into the cache
protected  T peek(ParameterizedType type)
          Peek into the cache
protected  void put(Class<?> clazz, T result)
          Put a result into the cache
protected  void put(ParameterizedType type, T result)
          Put a result into the cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeakTypeCache

public WeakTypeCache()
Method Detail

get

public T get(Type type)
Get the information for a type

Parameters:
type - the type
Returns:
the info

get

public T get(String name,
             ClassLoader cl)
      throws ClassNotFoundException
Get the information for a class

Parameters:
name - the name
cl - the classloader
Returns:
the info
Throws:
ClassNotFoundException - when the class cannot be found

instantiate

protected abstract T instantiate(Class<?> clazz)
Instantiate for a class

Parameters:
clazz - the class
Returns:
the result

generate

protected abstract void generate(Class<?> clazz,
                                 T result)
Fill in the result

Parameters:
clazz - the class
result - the result

instantiate

protected abstract T instantiate(ParameterizedType type)
Instantiate for a parameterized type

Parameters:
type - the parameterized type
Returns:
the result

generate

protected abstract void generate(ParameterizedType type,
                                 T result)
Fill in the result

Parameters:
type - the parameterized type
result - the result

getParameterizedType

protected T getParameterizedType(ParameterizedType type)
Get the information for a parameterized type

Parameters:
type - the parameterized type
Returns:
the info

getWildcardType

protected T getWildcardType(WildcardType type)
Get the information for a wildcard type

Parameters:
type - the paremeterized type
Returns:
the info

getTypeVariable

protected <D extends GenericDeclaration> T getTypeVariable(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(GenericArrayType type)
Get the information for an array type

Parameters:
type - the array type
Returns:
the info

peek

protected T peek(ParameterizedType type)
Peek into the cache

Parameters:
type - the type
Returns:
the value

put

protected void put(ParameterizedType type,
                   T result)
Put a result into the cache

Parameters:
type - the type
result - the value

getClass

protected T getClass(Class<?> clazz)
Get the information for a class

Parameters:
clazz - the class
Returns:
the info

peek

protected T peek(Class<?> clazz)
Peek into the cache

Parameters:
clazz - the class
Returns:
the value

put

protected void put(Class<?> clazz,
                   T result)
Put a result into the cache

Parameters:
clazz - the class
result - the value

getClassLoaderCache

protected Map<String,T> getClassLoaderCache(ClassLoader cl)
Get the cache for the classloader

Parameters:
cl - the classloader
Returns:
the map

JBoss Common Classes 2.2.17.GA

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.