org.jboss.util
Class WeakClassCache

java.lang.Object
  extended by org.jboss.util.WeakClassCache

public abstract class WeakClassCache
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:
Adrian Brock

Field Summary
protected  Map cache
          The cache
 
Constructor Summary
WeakClassCache()
           
 
Method Summary
protected abstract  void generate(Class clazz, Object result)
          Fill in the result
 Object get(Class clazz)
          Get the information for a class
 Object get(String name, ClassLoader cl)
          Get the information for a class
protected  Map getClassLoaderCache(ClassLoader cl)
          Get the cache for the classloader
protected abstract  Object instantiate(Class clazz)
          Instantiate for a class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

protected Map cache
The cache

Constructor Detail

WeakClassCache

public WeakClassCache()
Method Detail

get

public Object get(Class clazz)
Get the information for a class

Parameters:
clazz - the class
Returns:
the info

get

public Object 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 Object instantiate(Class clazz)
Instantiate for a class

Parameters:
clazz - the class
Returns:
the result

generate

protected abstract void generate(Class clazz,
                                 Object result)
Fill in the result

Parameters:
clazz - the class
the - result

getClassLoaderCache

protected Map getClassLoaderCache(ClassLoader cl)
Get the cache for the classloader

Parameters:
cl - the classloader
Returns:
the map


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.