1 19 20 package org.netbeans.modules.j2ee.oc4j.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.Datasource; 31 import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException; 32 import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping; 33 import org.netbeans.modules.j2ee.deployment.plugins.api.ConfigurationSupport; 34 35 40 public class ConfigurationSupportImpl extends ConfigurationSupport { 41 42 public void setMappingInfo(DeploymentConfiguration config, OriginalCMPMapping[] mappings) { 43 } 44 45 public void ensureResourceDefined(DeploymentConfiguration config, DDBean bean) { 46 } 47 48 public String getWebContextRoot(DeploymentConfiguration config, DeployableObject deplObj) 49 throws ConfigurationException { 50 if (config.getDeployableObject().getType() != ModuleType.WAR) { 51 throw new ConfigurationException ("This operation is supported only by the WAR modules"); } 53 if (!(config instanceof WarDeploymentConfiguration)) { 54 throw new IllegalArgumentException ("Wrong DeploymentConfiguration instance " + config.getClass().getName()); } 56 return ((WarDeploymentConfiguration)config).getContextPath(); 57 } 58 59 public void setWebContextRoot(DeploymentConfiguration config, DeployableObject deplObj, String contextRoot) 60 throws ConfigurationException { 61 if (config.getDeployableObject().getType() != ModuleType.WAR) { 62 throw new ConfigurationException ("This operation is supported only by the WAR modules."); } 64 if (!(config instanceof WarDeploymentConfiguration)) { 65 throw new IllegalArgumentException ("Wrong DeploymentConfiguration instance " + config.getClass().getName()); } 67 ((WarDeploymentConfiguration)config).setContextPath(contextRoot); 68 } 69 70 public void initConfiguration(DeploymentConfiguration config, File [] files, 71 File resourceDir, boolean keepUpdated) throws ConfigurationException { 72 if (!(config instanceof OC4JDeploymentConfiguration)) { 73 throw new IllegalArgumentException ("Wrong DeploymentConfiguration instance " + config.getClass().getName()); } 75 if (files == null || files.length != 1) { 76 throw new IllegalArgumentException ("Invalid value of the files argument."); } 78 ModuleType type = config.getDeployableObject().getType(); 79 if (type == ModuleType.WAR) { 80 ((WarDeploymentConfiguration)config).init(files[0], resourceDir); 81 } else if (type == ModuleType.EAR) { 82 ((EarDeploymentConfiguration)config).init(files[0], resourceDir); 83 } else if (type == ModuleType.EJB) { 84 ((EjbDeploymentConfiguration)config).init(files[0], resourceDir); 85 } else { 86 assert true : "Unsupported module type: " + type.toString(); } 88 } 89 90 public void disposeConfiguration(DeploymentConfiguration config) { 91 if (!(config instanceof OC4JDeploymentConfiguration)) { 92 throw new IllegalArgumentException ("Wrong DeploymentConfiguration instance " + config.getClass().getName()); } 94 } 95 96 public void updateResourceDir(DeploymentConfiguration config, File resourceDir) { 97 } 99 100 public Set <Datasource> getDatasources(DeploymentConfiguration config) { 101 Set <Datasource> projectDS = ((OC4JDeploymentConfiguration)config).getDatasources(); 102 return projectDS; 103 } 104 105 public boolean isDatasourceCreationSupported() { 106 return true; 107 } 108 109 public Datasource createDatasource(DeploymentConfiguration config, String jndiName, String url, String username, String password, String driver) 110 throws OperationUnsupportedException , ConfigurationException , DatasourceAlreadyExistsException { 111 OC4JDatasource ds = ((OC4JDeploymentConfiguration)config).createDatasource(jndiName, url, username, password, driver); 112 return ds; 113 } 114 } | Popular Tags |