[Ejtools-cvs] libraries/j2ee.deployment/src/main/javax/enterprise/deploy/shared/factories Deployment
Brought to you by:
letiemble
From: <let...@us...> - 2003-12-14 09:46:48
|
Update of /cvsroot/ejtools/libraries/j2ee.deployment/src/main/javax/enterprise/deploy/shared/factories In directory sc8-pr-cvs1:/tmp/cvs-serv4692/src/main/javax/enterprise/deploy/shared/factories Added Files: DeploymentFactoryManager.java package.html Log Message: Add up-to-date implementation for the JSR 88. No need for the Sun one. --- NEW FILE: DeploymentFactoryManager.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package javax.enterprise.deploy.shared.factories; import java.util.ArrayList; import java.util.Iterator; import javax.enterprise.deploy.spi.DeploymentManager; import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException; import javax.enterprise.deploy.spi.factories.DeploymentFactory; /** * The DeploymentFactoryManager class is a central registry for J2EE DeploymentFactory * objects. <p> * * The DeploymentFactoryManager retains references to DeploymentFactory objects loaded * by a tool.</p> <p> * * A DeploymentFactory object provides a reference to a DeploymentManager.</p> <p> * * The DeploymentFactoryManager has been implemented as a singleton. A tool gets * a reference to the DeploymentFactoryManager via the getInstance method.</p> <p> * * The DeploymentFactoryManager can return two types of DeploymentManagers, a connected * DeploymentManager and a disconnected DeploymentManager.</p> <p> * * 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.</p> * <p> * * 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. * <p> * * * * @author Laurent Etiemble * @version $Revision: 1.1 $ * @since 1.0 * @see javax.enterprise.deploy.spi.DeploymentManager * @see javax.enterprise.deploy.spi.factories.DeploymentFactory */ public final class DeploymentFactoryManager { private ArrayList factories = new ArrayList(); private static DeploymentFactoryManager instance = new DeploymentFactoryManager(); /** Private constructor for Singleton implementation */ private DeploymentFactoryManager() { } /** * Retrieve the lists of currently registered DeploymentFactories. * * @return the list of DeploymentFactory objects or an empty array if there * are none. */ public DeploymentFactory[] getDeploymentFactories() { return (DeploymentFactory[]) this.factories.toArray(new DeploymentFactory[this.factories.size()]); } /** * Retrieves a DeploymentManager instance to use for deployment. <p> * * 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.</p> * * @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. * @exception DeploymentManagerCreationException Occurs when the factory appropriate * to the specified URI was unable to initialize a DeploymentManager instance * (server down, unable to authenticate, etc.). */ public DeploymentManager getDeploymentManager(String uri, String username, String password) throws DeploymentManagerCreationException { if (uri == null) { throw new IllegalArgumentException("URI for DeploymentManager cannot be null"); } DeploymentManager manager = null; for (Iterator i = this.factories.iterator(); i.hasNext(); ) { DeploymentFactory factory = (DeploymentFactory) i.next(); if (factory.handlesURI(uri)) { manager = factory.getDeploymentManager(uri, username, password); break; } } if (manager == null) { throw new DeploymentManagerCreationException("Could not get a DeploymentManager; No registered DeploymentFactory handles URI '" + uri + "'."); } return manager; } /** * Return a disconnected DeploymentManager instance. <p> * * The caller provides a URI, and all registered DeploymentFactories will be checked. * The first one to understand the URI provided will return a ready DeploymentManager * instance.</p> * * @param uri The uri to check * @return A ready DeploymentManager instance. * @exception DeploymentManagerCreationException Occurs when the factory appropriate * to the specified URI was unable to initialize a DeploymentManager instance * (server down, etc.). */ public DeploymentManager getDisconnectedDeploymentManager(String uri) throws DeploymentManagerCreationException { if (uri == null) { throw new IllegalArgumentException("URI for DeploymentManager should not be null"); } DeploymentManager manager = null; for (Iterator i = this.factories.iterator(); i.hasNext(); ) { DeploymentFactory factory = (DeploymentFactory) i.next(); if (factory.handlesURI(uri)) { manager = factory.getDisconnectedDeploymentManager(uri); break; } } if (manager == null) { throw new DeploymentManagerCreationException("Could not get a DeploymentManager; No registered DeploymentFactory handles URI '" + uri + "'."); } return manager; } /** * Registers a DeploymentFactory so it will be able to handle requests. * * @param factory The DeploymentFactory to register */ public void registerDeploymentFactory(DeploymentFactory factory) { if (factory == null) { throw new IllegalArgumentException("DeploymentFactory to register cannot be null"); } if (!this.factories.contains(factory)) { this.factories.add(factory); } } /** * Retrieve the Singleton DeploymentFactoryManager * * @return The DeploymentFactoryManager instance */ public static DeploymentFactoryManager getInstance() { return DeploymentFactoryManager.instance; } } --- NEW FILE: package.html --- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!-- EJTools, the Enterprise Java Tools Distributable under LGPL license. See terms of license at www.gnu.org. $Revision: 1.1 $ --> <html> <head/> <body> Provides shared factory manager object for Tool Vendor and Product Vendor implementation classes. <h2>Package Specification</h2> <ul> <li><a href="http://jcp.org/jsr/detail/88.jsp">JSR 88, J2EE Application Deployment</a></li> </ul> <h2>Related Documentation</h2> For overviews, tutorials, examples, guides, and tool documentation, please see: <ul> <li><a href="http://java.sun.com/j2ee/tools">J2EE Tools</a></li> </ul> </body> </html> |