FileDocCategorySizeDatePackage
ApplicationRegistry.javaAPI DocGlassfish v2 API10193Fri May 04 22:35:40 BST 2007com.sun.enterprise.server

ApplicationRegistry

public final class ApplicationRegistry extends Object
Registry for all j2ee application and stand alone ejb modules in a server instance.
author
Mahesh Kannan
author
Nazrul Islam
since
JDK1.4

Fields Summary
protected Hashtable
appID2ClassLoader
application id vs class loader
protected Hashtable
moduleID2ClassLoader
stand alone module id vs class loader
protected Hashtable
classLoader2Application
ClassLoader vs Application Objects
protected Hashtable
descriptor2Container
EJBDescriptor vs Container
private HashSet
uniqueIds
holds unique ids of ejb containers for each deployed applications
private static ApplicationRegistry
_instance
the singleton instance
Constructors Summary
private ApplicationRegistry()
Initializes the registry.

        this.appID2ClassLoader        = new Hashtable();
        this.moduleID2ClassLoader     = new Hashtable();
        this.descriptor2Container     = new Hashtable();
        this.classLoader2Application  = new Hashtable();
        this.uniqueIds                = new HashSet();
    
Methods Summary
voidaddAppId2ClassLoader(java.lang.String appID, java.lang.ClassLoader classLoader)
Stores class loader against the given registration name for application.

param
appID registration name of the application
param
classLoader class loader associated with this application

        appID2ClassLoader.put(appID, classLoader);
    
voidaddClassLoader2Application(java.lang.ClassLoader classLoader, com.sun.enterprise.deployment.Application app)
Stores the deployment descriptor hierarchy against the class loader.

param
classLoader class loader used in an app
param
app deployment descriptor hierarchy


        classLoader2Application.put(classLoader, app);
    
voidaddDescriptor2Container(com.sun.enterprise.deployment.EjbDescriptor desc, com.sun.ejb.Container container)
Stores the given deployment descriptor and ejb container in a table.

param
desc deployment descriptor of an ejb
param
container ejb container


        descriptor2Container.put(desc, container);
    
voidaddModuleId2ClassLoader(java.lang.String moduleID, java.lang.ClassLoader classLoader)
Stores class loader against the given registration name for stand alone module. We are keeping separate table because of possible name space collision.

param
moduleID registration name of stand alone module
param
classLoader class loader associated with this module

        moduleID2ClassLoader.put(moduleID, classLoader);
    
java.util.CollectiongetAllEjbContainers()
Returns all the ejb containers available in this registry. This includes J2EE applications and stand alone ejb modules.

return
a collection of ejb containers


        Collection containers = null;

        if (this.descriptor2Container != null) {
            containers =  this.descriptor2Container.values();
        }

        return containers;
    
public com.sun.enterprise.deployment.ApplicationgetApplication(java.lang.ClassLoader loader)
Return the Application for the given classloader. It is assumed that there is a 1-to-1 mapping from app to loader. This is called at runtime from the Persistence Manager.

param
loader class loader
return
deployment descriptor hierarchy for the given class loader

        return (Application) classLoader2Application.get(loader);
    
public java.lang.ClassLoadergetClassLoaderForApplication(java.lang.String appID)
Get the class loader of a given application. Used in ServletDeployerImpl

param
appID registration name of an application
return
the class loader for the given registration name

        return (ClassLoader) appID2ClassLoader.get(appID);
    
public java.lang.ClassLoadergetClassLoaderForModule(java.lang.String moduleID)
Get the class loader of the given stand alone module.

param
moduleID registration name of a stand alone module
return
the class loader for the given stand alone module registration name

        return (ClassLoader) moduleID2ClassLoader.get(moduleID);
    
public com.sun.ejb.ContainergetContainer(com.sun.enterprise.deployment.EjbDescriptor desc)
Return the Container for the given EjbDescriptor. This is called at runtime from the Persistence Manager.

param
desc ejb deployment descriptor
return
the ejb container for the given descriptor obj

        return (Container) descriptor2Container.get(desc);
    
public static com.sun.enterprise.server.ApplicationRegistrygetInstance()
Returns the singleton instance.

return
the singleton instance

        _instance = new ApplicationRegistry();
    
        return _instance;
    
booleanisUnique(long uniqueId)
Returns true if the given id is not already present in this registry. It adds the specified unique id to the registry if not already present. This is used to detect collision between two ejb bean containers.

param
uniqueId unique id of an ejb bean container
return
true if the given id is not already present in this registry

        return this.uniqueIds.add( new Long(uniqueId) );
    
java.lang.ClassLoaderremoveAppId2ClassLoader(java.lang.String appID)
Removes the class loader associated with the given registration name.

param
appID registration name of an app
return
the removed class loader

        return (ClassLoader) appID2ClassLoader.remove(appID);
    
com.sun.enterprise.deployment.ApplicationremoveClassLoader2Application(java.lang.ClassLoader cl)
Removes the deployment descriptor hierarchy associated with the given class loader.

param
cl class loader used in an app
return
the removed deployment descriptor hierarchy

        return (Application) classLoader2Application.remove(cl);
    
com.sun.ejb.ContainerremoveDescriptor2Container(com.sun.enterprise.deployment.EjbDescriptor desc)
Removes the ejb container associated with the given deployment descriptor.

param
desc ejb deployment descriptor
return
the removed ejb container

        return (Container) descriptor2Container.remove(desc);
    
java.lang.ClassLoaderremoveModuleId2ClassLoader(java.lang.String moduleID)
Removes the class loader associated with the given stand alone module registration name. We are keeping separate table because of possible name space collision.

param
moduleID registration name of stand alone module
return
the removed class loader

        return (ClassLoader) moduleID2ClassLoader.remove(moduleID);
    
booleanremoveUniqueId(long uniqueId)
Removes the given id from this registry.

param
uniqueId unique if of an ejb bean container
return
true if the registry contained the specified id

        return this.uniqueIds.remove( new Long(uniqueId) );