1 23 24 37 package com.sun.enterprise.server; 38 39 import java.util.Hashtable ; 40 import java.util.HashSet ; 41 import java.util.Collection ; 42 43 import com.sun.ejb.Container; 44 import com.sun.enterprise.deployment.Application; 45 import com.sun.enterprise.deployment.EjbDescriptor; 46 47 55 public final class ApplicationRegistry { 56 57 58 protected Hashtable appID2ClassLoader; 59 60 61 protected Hashtable moduleID2ClassLoader; 62 63 64 protected Hashtable classLoader2Application; 65 66 67 protected Hashtable descriptor2Container; 68 69 70 private HashSet uniqueIds; 71 72 73 private static ApplicationRegistry _instance; 74 75 static { 76 _instance = new ApplicationRegistry(); 77 } 78 79 84 public static ApplicationRegistry getInstance() { 85 return _instance; 86 } 87 88 91 private ApplicationRegistry() { 92 this.appID2ClassLoader = new Hashtable (); 93 this.moduleID2ClassLoader = new Hashtable (); 94 this.descriptor2Container = new Hashtable (); 95 this.classLoader2Application = new Hashtable (); 96 this.uniqueIds = new HashSet (); 97 } 98 99 100 101 109 public Container getContainer(EjbDescriptor desc) { 110 return (Container) descriptor2Container.get(desc); 111 } 112 113 123 public Application getApplication(ClassLoader loader) { 124 return (Application) classLoader2Application.get(loader); 125 } 126 127 135 public ClassLoader getClassLoaderForApplication(String appID) { 136 return (ClassLoader ) appID2ClassLoader.get(appID); 137 } 138 139 140 141 149 public ClassLoader getClassLoaderForModule(String moduleID) { 150 return (ClassLoader ) moduleID2ClassLoader.get(moduleID); 151 } 152 153 159 void addDescriptor2Container(EjbDescriptor desc, 160 Container container) { 161 162 descriptor2Container.put(desc, container); 163 } 164 165 171 void addAppId2ClassLoader(String appID, ClassLoader classLoader) { 172 appID2ClassLoader.put(appID, classLoader); 173 } 174 175 183 void addModuleId2ClassLoader(String moduleID, ClassLoader classLoader) { 184 moduleID2ClassLoader.put(moduleID, classLoader); 185 } 186 187 193 void addClassLoader2Application(ClassLoader classLoader, 194 Application app) { 195 196 classLoader2Application.put(classLoader, app); 197 } 198 199 206 Container removeDescriptor2Container(EjbDescriptor desc) { 207 return (Container) descriptor2Container.remove(desc); 208 } 209 210 216 ClassLoader removeAppId2ClassLoader(String appID) { 217 return (ClassLoader ) appID2ClassLoader.remove(appID); 218 } 219 220 228 ClassLoader removeModuleId2ClassLoader(String moduleID) { 229 return (ClassLoader ) moduleID2ClassLoader.remove(moduleID); 230 } 231 232 239 Application removeClassLoader2Application(ClassLoader cl) { 240 return (Application) classLoader2Application.remove(cl); 241 } 242 243 253 boolean isUnique(long uniqueId) { 254 return this.uniqueIds.add( new Long (uniqueId) ); 255 } 256 257 264 boolean removeUniqueId(long uniqueId) { 265 return this.uniqueIds.remove( new Long (uniqueId) ); 266 } 267 268 274 Collection getAllEjbContainers() { 275 276 Collection containers = null; 277 278 if (this.descriptor2Container != null) { 279 containers = this.descriptor2Container.values(); 280 } 281 282 return containers; 283 } 284 } 285 | Popular Tags |