[Ejtools-cvs] CVS: libraries/jboss.provider/src/main/org/jboss/enterprise/deploy/spi/factories JBoss
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-05-01 18:45:32
|
Update of /cvsroot/ejtools/libraries/jboss.provider/src/main/org/jboss/enterprise/deploy/spi/factories In directory usw-pr-cvs1:/tmp/cvs-serv15366/jboss.provider/src/main/org/jboss/enterprise/deploy/spi/factories Added Files: JBoss30DeploymentFactory.java JBossDeploymentFactoryManager.java Log Message: Initial Import --- NEW FILE: JBoss30DeploymentFactory.java --- package org.jboss.enterprise.deploy.spi.factories; import javax.enterprise.deploy.spi.factories.DeploymentFactory; import javax.enterprise.deploy.spi.DeploymentManager; import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException; import org.jboss.enterprise.deploy.spi.*; /** * Description of the Class * * @author laurent * @created 23 mars 2002 */ public class JBoss30DeploymentFactory implements DeploymentFactory { /** Description of the Field */ protected final static String DISPLAY_NAME = "JBoss Deployement Manager"; /** Description of the Field */ protected final static String PRODUCT_VERSION = "V1.0.0 - JBoss 3.0"; /** Description of the Field */ protected final static String URL_START = "deployer:jboss30:"; /** * Getter for the deploymentManager attribute * * @param uri Description of Parameter * @param username Description of Parameter * @param password Description of Parameter * @return The value * @exception DeploymentManagerCreationException Description of Exception */ public DeploymentManager getDeploymentManager(String uri, String username, String password) throws DeploymentManagerCreationException { return new JBoss30DeploymentManager(uri, username, password); } /** * Getter for the disconnectedDeploymentManager attribute * * @param uri Description of Parameter * @return The value * @exception DeploymentManagerCreationException Description of Exception */ public DeploymentManager getDisconnectedDeploymentManager(String uri) throws DeploymentManagerCreationException { return new JBoss30DeploymentManager(uri); } /** * Getter for the displayname attribute * * @return The value */ public String getDisplayname() { return DISPLAY_NAME; } /** * Getter for the productVersion attribute * * @return The value */ public String getProductVersion() { return PRODUCT_VERSION; } /** * Description of the Method * * @param uri Description of Parameter * @return Description of the Returned Value */ public boolean handlesURI(String uri) { if (uri.startsWith(URL_START)) { return true; } return false; } } --- NEW FILE: JBossDeploymentFactoryManager.java --- package org.jboss.enterprise.deploy.spi.factories; import java.util.StringTokenizer; import java.util.Vector; import javax.enterprise.deploy.spi.DeploymentManager; import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException; import javax.enterprise.deploy.spi.factories.DeploymentFactory; import javax.enterprise.deploy.spi.factories.DeploymentFactoryManager; /** * Description of the Class * * @author laurent * @created 31 mars 2002 */ public class JBossDeploymentFactoryManager implements DeploymentFactoryManager { /** Description of the Field */ private static Vector factories = new Vector(); /** Description of the Field */ private static boolean initialized = false; /** Constructor */ public JBossDeploymentFactoryManager() { } /** * Retrieve the lists of currently registered DeploymentFactories. * * @return the list of DeploymentFactory objects or 'null' if there are * none. */ public DeploymentFactory[] getDeploymentFactories() { this.initialize(); return (DeploymentFactory[]) this.factories.toArray(new DeploymentFactory[0]); } /** * Return a <tt>disconnected</tt> DeploymentManager instance. * * @param uri identifier of the * disconnected DeploymentManager to return. * @return A DeploymentManager * instance. * @exception DeploymentManagerCreationException Description of Exception * @throws DeploymentDriverException occurs if the * DeploymentManager could not be created. */ public DeploymentManager getDisconnectedDeploymentManager(String uri) throws DeploymentManagerCreationException { this.initialize(); for (int i = 0; i < this.factories.size(); i++) { DeploymentFactory factory = (DeploymentFactory) this.factories.elementAt(i); if (factory.handlesURI(uri)) { return factory.getDisconnectedDeploymentManager(uri); } } return null; } /** * 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 * <tt>null</tt> if no authentication is required for this platform). * @param password An optional password (may be * <tt>null</yy> 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.). */ public DeploymentManager getDeploymentManager(String uri, String username, String password) throws DeploymentManagerCreationException { this.initialize(); for (int i = 0; i < this.factories.size(); i++) { DeploymentFactory factory = (DeploymentFactory) this.factories.elementAt(i); if (factory.handlesURI(uri)) { return factory.getDeploymentManager(uri, username, password); } } return null; } /** * Registers a DeploymentFactory so it will be able to handle requests. * * @param factory Description of Parameter */ public void registerDeploymentFactory(DeploymentFactory factory) { this.initialize(); this.factories.add(factory); } /** Description of the Method */ private void initialize() { if (this.initialized) { return; } this.initialized = true; this.loadInitialFactories(); } /** Description of the Method */ private void loadInitialFactories() { String factoriesToLoad; factoriesToLoad = System.getProperty("javax.enterprise.deploy.spi.factories"); System.out.println("ENV " + factoriesToLoad); if (factoriesToLoad == null) { return; } StringTokenizer tokenizer = new StringTokenizer(factoriesToLoad, ":"); while (tokenizer.hasMoreTokens()) { String factoryToLoad = tokenizer.nextToken(); System.out.println("NEXT " + factoryToLoad); try { DeploymentFactory factory = (DeploymentFactory) Class.forName(factoryToLoad).newInstance(); this.registerDeploymentFactory(factory); } catch (ClassNotFoundException ex) { } catch (Exception ex) { } } } } |