FileDocCategorySizeDatePackage
ClientJarMakerRegistry.javaAPI DocGlassfish v2 API4864Fri May 04 22:34:30 BST 2007com.sun.enterprise.deployment.backend

ClientJarMakerRegistry

public class ClientJarMakerRegistry extends Object
All client jar file are created in a separate thread when the client jar file is not requested at deployment time. These threads are registered in this singleton registry so that when client jar files are requested from the deployment clients, we check if the client jar file is not in the process of being created.
author
Jerome Dochez

Fields Summary
private static ClientJarMakerRegistry
theRegistry
Map
registeredThreads
Constructors Summary
protected ClientJarMakerRegistry()
Creates a new instance of ClientJarMakerRegistry

    
           
      
        // I use hashtable since it needs to synchronized
        registeredThreads = new Hashtable();
    
Methods Summary
public static synchronized com.sun.enterprise.deployment.backend.ClientJarMakerRegistrygetInstance()

return
the singleton instance of ClientJarMakerRegistry

        
        if (theRegistry==null) {
            theRegistry = new ClientJarMakerRegistry();
        }
        return theRegistry;
    
public booleanisRegistered(java.lang.String moduleID)

return
true if the passed module ID has a registered thread

        
        return registeredThreads.containsKey(moduleID);
    
public voidregister(java.lang.String moduleID, java.lang.Thread clientJarMaker)
Register a new thread in the registry

param
the module ID we are creating the client jar for
param
the thread object responsible for creating the client jar file

        
        registeredThreads.put(moduleID, clientJarMaker);
    
public voidunregister(java.lang.String moduleID)
Unregister a thread in the registry. This is done when the thread has finished its execution

param
the module ID identifying the module this thread was creating the client jar for.

        
        registeredThreads.remove(moduleID);
    
public voidwaitForCompletion(java.lang.String moduleID)
wait for a particular thread maker to finish process before returning

        
        Thread maker = (Thread) registeredThreads.get(moduleID);
        if (maker==null) 
            return;
        
        try {
            maker.join();
        } catch(InterruptedException e) {
            StringManager localStrings = StringManager.getManager( ClientJarMakerRegistry.class );            
            DeploymentLogger.get().log(Level.SEVERE, 
                localStrings.getString("enterprise.deployment.error_creating_client_jar", 
                    e.getLocalizedMessage()) ,e);            
        }
        
        return;