1 16 17 package org.apache.axis.utils.cache; 18 19 import org.apache.axis.utils.ClassUtils; 20 21 import java.util.Hashtable ; 22 23 30 public class ClassCache { 31 Hashtable classCache = new Hashtable (); 32 33 public ClassCache() { 34 } 35 36 44 public synchronized void registerClass(String name, Class cls) { 45 if (name == null) return; JavaClass oldClass = (JavaClass) classCache.get(name); 47 if (oldClass != null && oldClass.getJavaClass() == cls) return; 48 classCache.put(name, new JavaClass(cls)); 49 } 50 51 56 public synchronized void deregisterClass(String name) { 57 classCache.remove(name); 58 } 59 60 66 public boolean isClassRegistered(String name) { 67 return (classCache != null && classCache.get(name) != null); 68 } 69 70 77 public JavaClass lookup(String className, ClassLoader cl) 78 throws ClassNotFoundException { 79 if (className == null) { 80 return null; 81 } 82 JavaClass jc = (JavaClass) classCache.get(className); 83 if ((jc == null) && (cl != null)) { 84 Class cls = ClassUtils.forName(className, true, cl); 86 jc = new JavaClass(cls); 87 } 88 return jc; 89 } 90 } 91 92 ; 93 | Popular Tags |