1 22 package org.jboss.deployment.spi.factories; 23 24 26 import java.net.URI ; 27 import java.net.URISyntaxException ; 28 29 import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager ; 30 import javax.enterprise.deploy.spi.DeploymentManager ; 31 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException ; 32 import javax.enterprise.deploy.spi.factories.DeploymentFactory ; 33 34 import org.jboss.deployment.spi.DeploymentManagerImpl; 35 import org.jboss.logging.Logger; 36 37 57 public class DeploymentFactoryImpl implements DeploymentFactory 58 { 59 private static final Logger log = Logger.getLogger(DeploymentFactoryImpl.class); 61 62 private static String DISPLAY_NAME; 64 private static String PRODUCT_VERSION; 66 67 70 static 71 { 72 Package pkg = Package.getPackage("org.jboss.deploy.spi.factories"); 73 if (pkg != null) 74 { 75 DISPLAY_NAME = pkg.getImplementationVendor(); 76 PRODUCT_VERSION = pkg.getImplementationVersion(); 77 } 78 if (DISPLAY_NAME == null || PRODUCT_VERSION == null) 79 { 80 DISPLAY_NAME = "DeploymentFactoryImpl"; 81 PRODUCT_VERSION = "1.1-DEV"; 82 } 83 84 DeploymentFactoryManager manager = DeploymentFactoryManager.getInstance(); 86 manager.registerDeploymentFactory(new DeploymentFactoryImpl()); 87 } 88 89 96 public boolean handlesURI(String uri) 97 { 98 boolean handlesURI = DeploymentManagerImpl.DEPLOYER_URI.equals(uri); 99 if (handlesURI == false) 100 { 101 try 102 { 103 URI deployURI = parseURI(uri); 104 handlesURI = "jnp".equals(deployURI.getScheme()); 105 } 106 catch (URISyntaxException e) 107 { 108 log.warn("Failed to parse uri: " + uri, e); 109 } 110 } 111 112 log.debug("handlesURI [" + uri + "]: " + handlesURI); 113 return handlesURI; 114 } 115 116 126 public DeploymentManager getDeploymentManager(String uri, String userName, String password) throws DeploymentManagerCreationException 127 { 128 log.debug("getDeploymentManager (uri=" + uri + ")"); 129 DeploymentManager mgr = null; 130 131 try 132 { 133 URI deployURI = parseURI(uri); 134 mgr = new DeploymentManagerImpl(deployURI, true, userName, password); 135 } 136 catch (URISyntaxException e) 137 { 138 DeploymentManagerCreationException ex = new DeploymentManagerCreationException ("Failed to create DeploymentManagerImpl"); 139 ex.initCause(e); 140 throw ex; 141 } 142 return mgr; 143 } 144 145 153 public DeploymentManager getDisconnectedDeploymentManager(String uri) throws DeploymentManagerCreationException 154 { 155 log.debug("getDisconnectedDeploymentManager (uri=" + uri + ")"); 156 DeploymentManager mgr = null; 157 158 try 159 { 160 URI deployURI = parseURI(uri); 161 mgr = new DeploymentManagerImpl(deployURI, false); 162 } 163 catch (URISyntaxException e) 164 { 165 DeploymentManagerCreationException ex = new DeploymentManagerCreationException ("Failed to create DeploymentManagerImpl"); 166 ex.initCause(e); 167 throw ex; 168 } 169 return mgr; 170 } 171 172 177 public String getDisplayName() 178 { 179 return DISPLAY_NAME; 180 } 181 182 187 public String getProductVersion() 188 { 189 return PRODUCT_VERSION; 190 } 191 192 private URI parseURI(String uri) throws URISyntaxException 193 { 194 URI deployURI = new URI (uri); 195 return deployURI; 196 } 197 } 198 | Popular Tags |