1 19 20 package org.netbeans.modules.j2ee.jboss4.config; 21 22 import java.io.File ; 23 import java.util.Set ; 24 import javax.enterprise.deploy.model.DDBean ; 25 import javax.enterprise.deploy.model.DeployableObject ; 26 import javax.enterprise.deploy.shared.ModuleType ; 27 import javax.enterprise.deploy.spi.DeploymentConfiguration ; 28 import javax.enterprise.deploy.spi.exceptions.ConfigurationException ; 29 import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException ; 30 import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping; 31 import org.netbeans.modules.j2ee.deployment.plugins.api.ConfigurationSupport; 32 import org.netbeans.modules.j2ee.deployment.common.api.Datasource; 33 import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException; 34 35 36 37 38 43 public class ConfigurationSupportImpl extends ConfigurationSupport { 44 45 public void setMappingInfo(DeploymentConfiguration config, OriginalCMPMapping[] mappings) { 46 } 47 48 public void ensureResourceDefined(DeploymentConfiguration config, DDBean bean) { 49 } 50 51 public String getWebContextRoot(DeploymentConfiguration config, DeployableObject deplObj) 52 throws ConfigurationException { 53 if (config.getDeployableObject().getType() != ModuleType.WAR) { 54 throw new ConfigurationException ("This operation is supported only by the WAR modules"); } 56 if (!(config instanceof WarDeploymentConfiguration)) { 57 throw new IllegalArgumentException ("Wrong DeploymentConfiguration instance " + config.getClass().getName()); } 59 return ((WarDeploymentConfiguration)config).getContextPath(); 60 } 61 62 public void setWebContextRoot(DeploymentConfiguration config, DeployableObject deplObj, String contextRoot) 63 throws ConfigurationException { 64 if (config.getDeployableObject().getType() != ModuleType.WAR) { 65 throw new ConfigurationException ("This operation is supported only by the WAR modules."); } 67 if (!(config instanceof WarDeploymentConfiguration)) { 68 throw new IllegalArgumentException ("Wrong DeploymentConfiguration instance " + config.getClass().getName()); } 70 ((WarDeploymentConfiguration)config).setContextPath(contextRoot); 71 } 72 73 public void initConfiguration(DeploymentConfiguration config, File [] files, 74 File resourceDir, boolean keepUpdated) throws ConfigurationException { 75 if (!(config instanceof JBDeploymentConfiguration)) { 76 throw new IllegalArgumentException ("Wrong DeploymentConfiguration instance " + config.getClass().getName()); } 78 if (files == null || files.length != 1) { 79 throw new IllegalArgumentException ("Invalid value of the files argument."); } 81 ModuleType type = config.getDeployableObject().getType(); 82 if (type == ModuleType.WAR) { 83 ((WarDeploymentConfiguration)config).init(files[0], resourceDir); 84 } else if (type == ModuleType.EAR) { 85 ((EarDeploymentConfiguration)config).init(files[0]); 86 } else if (type == ModuleType.EJB) { 87 ((EjbDeploymentConfiguration)config).init(files[0], resourceDir); 88 } else if (type == ModuleType.CAR) { 89 ((CarDeploymentConfiguration)config).init(files[0], resourceDir); 90 } else { 91 assert true : "Unsupported module type: " + type.toString(); } 93 } 94 95 public void disposeConfiguration(DeploymentConfiguration config) { 96 if (!(config instanceof JBDeploymentConfiguration)) { 97 throw new IllegalArgumentException ("Wrong DeploymentConfiguration instance " + config.getClass().getName()); } 99 } 100 101 public void updateResourceDir(DeploymentConfiguration config, File resourceDir) { 102 } 104 105 public Set <Datasource> getDatasources(DeploymentConfiguration config) { 106 Set <Datasource> projectDS = ((JBDeploymentConfiguration)config).getDatasources(); 107 return projectDS; 108 } 109 110 public boolean isDatasourceCreationSupported() { 111 return true; 112 } 113 114 public Datasource createDatasource(DeploymentConfiguration config, String jndiName, String url, String username, String password, String driver) 115 throws OperationUnsupportedException , ConfigurationException , DatasourceAlreadyExistsException 116 { 117 JBossDatasource ds = ((JBDeploymentConfiguration)config).createDatasource(jndiName, url, username, password, driver); 118 return ds; 119 } 120 121 } 122 | Popular Tags |