1 54 55 package org.jboss.axis.utils.cache; 56 57 import org.jboss.axis.utils.ClassUtils; 58 59 import java.util.Hashtable ; 60 61 68 public class ClassCache 69 { 70 Hashtable classCache = new Hashtable (); 71 72 public ClassCache() 73 { 74 } 75 76 84 public synchronized void registerClass(String name, Class cls) 85 { 86 if (name == null) return; JavaClass oldClass = (JavaClass)classCache.get(name); 88 if (oldClass != null && oldClass.getJavaClass() == cls) return; 89 classCache.put(name, new JavaClass(cls)); 90 } 91 92 97 public synchronized void deregisterClass(String name) 98 { 99 classCache.remove(name); 100 } 101 102 108 public boolean isClassRegistered(String name) 109 { 110 return (classCache != null && classCache.get(name) != null); 111 } 112 113 121 public JavaClass lookup(String className, ClassLoader cl) 122 throws ClassNotFoundException 123 { 124 if (className == null) 125 { 126 return null; 127 } 128 JavaClass jc = (JavaClass)classCache.get(className); 129 if ((jc == null) && (cl != null)) 130 { 131 Class cls = ClassUtils.forName(className, true, cl); 133 jc = new JavaClass(cls); 134 } 135 return jc; 136 } 137 } 138 139 ; 140 | Popular Tags |