ClassCachepublic class ClassCache extends Object A cache class for JavaClass objects, which enables us to quickly reference
methods. |
Fields Summary |
---|
Hashtable | classCache |
Constructors Summary |
---|
public ClassCache()
|
Methods Summary |
---|
public synchronized void | deregisterClass(java.lang.String name)Remove an entry from the cache.
classCache.remove(name);
| public boolean | isClassRegistered(java.lang.String name)Query a given class' cache status.
return (classCache != null && classCache.get(name) != null);
| public JavaClass | lookup(java.lang.String className, java.lang.ClassLoader cl)Find the cached JavaClass entry for this class, creating one
if necessary.
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 void | registerClass(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.
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));
|
|