FileDocCategorySizeDatePackage
DeploymentFactoryManager.javaAPI DocGlassfish v2 API8138Fri May 04 22:35:48 BST 2007javax.enterprise.deploy.shared.factories

DeploymentFactoryManager

public final class DeploymentFactoryManager extends Object
The DeploymentFactoryManager class is a central registry for J2EE DeploymentFactory objects. The DeploymentFactoryManager retains references to DeploymentFactory objects loaded by a tool. A DeploymentFactory object provides a reference to a DeploymentManager. The DeploymentFactoryManager has been implemented as a singleton. A tool gets a reference to the DeploymentFactoryManager via the getInstance method. The DeploymentFactoryManager can return two types of DeploymentManagers, a connected DeploymentManager and a disconnected DeploymentManager. The connected DeploymentManager provides access to any product resources that may be required for configurations and deployment. The method to retrieve a connected DeploymentManager is getDeploymentManager. This method provides parameters for user name and password that the product may require for user authentication. A disconnected DeploymentManager does not provide access to a running J2EE product. The method to retrieve a disconnected DeploymentManager is getDisconnectedDeploymentManager. A disconnected DeploymentManager does not need user authentication information.

Fields Summary
private Vector
deploymentFactories
private static DeploymentFactoryManager
deploymentFactoryManager
Constructors Summary
private DeploymentFactoryManager()
Creates new RIDeploymentFactoryManager

    
        
      
        deploymentFactories = new Vector();
    
Methods Summary
public javax.enterprise.deploy.spi.factories.DeploymentFactory[]getDeploymentFactories()
Retrieve the lists of currently registered DeploymentFactories.

return
the list of DeploymentFactory objects or an empty array if there are none.

        Vector deploymentFactoriesSnapShot = null;
        synchronized(this){
            deploymentFactoriesSnapShot = 
				(Vector)this.deploymentFactories.clone();
        }
        DeploymentFactory[] factoriesArray = 
			new DeploymentFactory[deploymentFactoriesSnapShot.size()];
        deploymentFactoriesSnapShot.copyInto(factoriesArray);
        return factoriesArray;
    
public javax.enterprise.deploy.spi.DeploymentManagergetDeploymentManager(java.lang.String uri, java.lang.String username, java.lang.String password)
Retrieves a DeploymentManager instance to use for deployment. The caller provides a URI and optional username and password, and all registered DeploymentFactories will be checked. The first one to understand the URI provided will attempt to initiate a server connection and return a ready DeploymentManager instance.

param
uri The uri to check
param
username An optional username (may be null if no authentication is required for this platform).
param
password An optional password (may be null if no authentication is required for this platform).
return
A ready DeploymentManager instance.
throws
DeploymentManagerCreationException Occurs when the factory appropriate to the specified URI was unable to initialize a DeploymentManager instance (server down, unable to authenticate, etc.).

        try{
            DeploymentFactory[] factories = this.getDeploymentFactories();
            for(int factoryIndex=0; factoryIndex < factories.length; 
				factoryIndex++){
                if(factories[factoryIndex].handlesURI(uri)){
                    return factories[factoryIndex].getDeploymentManager(uri,
							username,password);
                }
            }
            // No available factory supports the provided url.
            throw new DeploymentManagerCreationException("URL ["+uri+
				"] not supported by any available factories");
        }catch(Throwable t){
            throw new DeploymentManagerCreationException(
				"Could not get DeploymentManager");
        }
    
public javax.enterprise.deploy.spi.DeploymentManagergetDisconnectedDeploymentManager(java.lang.String uri)
Return a disconnected DeploymentManager instance.

param
uri identifier of the disconnected DeploymentManager to return.
return
A DeploymentManager instance.
throws
DeploymentDriverException occurs if the DeploymentManager could not be created.

        try{
            DeploymentFactory[] factories = this.getDeploymentFactories();
            for(int factoryIndex=0; factoryIndex < factories.length; 
				factoryIndex++){
                if(factories[factoryIndex].handlesURI(uri)){
                    return factories[factoryIndex].getDisconnectedDeploymentManager(uri);
                }
            }
            // No available factory supports the provided url.
            throw new DeploymentManagerCreationException("URL ["+uri+
				"] not supported by any available factories");
        }catch(Throwable t){
            throw new DeploymentManagerCreationException(
				"Could not get DeploymentManager");
        }
    
public static javax.enterprise.deploy.shared.factories.DeploymentFactoryManagergetInstance()
Retrieve the Singleton DeploymentFactoryManager

return
DeploymentFactoryManager instance

        if(deploymentFactoryManager == null){
            deploymentFactoryManager = new DeploymentFactoryManager();
        }
        return deploymentFactoryManager;
    
public voidregisterDeploymentFactory(javax.enterprise.deploy.spi.factories.DeploymentFactory factory)
Registers a DeploymentFactory so it will be able to handle requests.

        this.deploymentFactories.add(factory);