FileDocCategorySizeDatePackage
ClassCache.javaAPI DocApache Axis 1.42872Sat Apr 22 18:57:28 BST 2006org.apache.axis.utils.cache

ClassCache

public class ClassCache extends Object
A cache class for JavaClass objects, which enables us to quickly reference methods.
author
Doug Davis (dug@us.ibm.com)
author
Glen Daniels (gdaniels@apache.org)

Fields Summary
Hashtable
classCache
Constructors Summary
public ClassCache()


      
    
Methods Summary
public synchronized voidderegisterClass(java.lang.String name)
Remove an entry from the cache.

param
name the name of the class to remove.

        classCache.remove(name);
    
public booleanisClassRegistered(java.lang.String name)
Query a given class' cache status.

param
name a class name
return
true if the class is in the cache, false otherwise

        return (classCache != null && classCache.get(name) != null);
    
public JavaClasslookup(java.lang.String className, java.lang.ClassLoader cl)
Find the cached JavaClass entry for this class, creating one if necessary.

param
className name of the class desired
param
cl ClassLoader to use if we need to load the class
return
JavaClass entry

        if (className == null) {
            return null;
        }
        JavaClass jc = (JavaClass) classCache.get(className);
        if ((jc == null) && (cl != null)) {
            // Try to load the class with the specified classloader
            Class cls = ClassUtils.forName(className, true, cl);
            jc = new JavaClass(cls);
        }
        return jc;
    
public synchronized voidregisterClass(java.lang.String name, java.lang.Class cls)
Register a class in the cache. Creates a new JavaClass object around the given class, and inserts it into the Hashtable, replacing any previous entry.

param
name the name of the class.
param
cls a Java Class.

        if (name == null) return; // ??? Should we let this NPE?
        JavaClass oldClass = (JavaClass) classCache.get(name);
        if (oldClass != null && oldClass.getJavaClass() == cls) return;
        classCache.put(name, new JavaClass(cls));