1 19 24 25 package org.netbeans.modules.j2ee.sun.ide.j2ee; 26 27 import java.io.File ; 28 import java.util.Set ; 29 30 import javax.enterprise.deploy.model.DDBean ; 31 import javax.enterprise.deploy.model.DeployableObject ; 32 import javax.enterprise.deploy.spi.DeploymentConfiguration ; 33 import javax.enterprise.deploy.spi.exceptions.ConfigurationException ; 34 import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException ; 35 import org.netbeans.modules.j2ee.deployment.common.api.Datasource; 36 import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException; 37 38 import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping; 39 import org.netbeans.modules.j2ee.deployment.plugins.api.ConfigurationSupport; 40 import org.netbeans.modules.j2ee.sun.share.configbean.EjbJarRoot; 41 import org.netbeans.modules.j2ee.sun.share.configbean.SunONEDeploymentConfiguration; 42 43 50 public class ConfigurationSupportImpl extends ConfigurationSupport { 51 52 53 public ConfigurationSupportImpl() { 54 } 55 56 57 60 public void initConfiguration(DeploymentConfiguration config, File [] files, File resourceDir, boolean keepUpdated) throws ConfigurationException { 61 checkConfiguration(config); 62 if(files == null || files.length < 1 || files[0] == null) { 63 throw new IllegalArgumentException ("files[] must be non-null and contain at least one non-null member."); 64 } 65 ((SunONEDeploymentConfiguration)config).init(files, resourceDir, keepUpdated); 66 } 67 68 69 72 public void disposeConfiguration(DeploymentConfiguration config) { 73 checkConfiguration(config); 74 ((SunONEDeploymentConfiguration)config).dispose(); 75 } 76 77 78 81 public void ensureResourceDefined(DeploymentConfiguration config, DDBean ddBean) { 82 checkConfiguration(config); 83 if(ddBean == null) { 84 throw new IllegalArgumentException ("DDBean parameter cannot be null."); 85 } 86 ((SunONEDeploymentConfiguration)config).ensureResourceDefined(ddBean); 87 } 88 89 92 public void ensureResourceDefined(DeploymentConfiguration config, DDBean ddBean, String jndiName) { 93 checkConfiguration(config); 94 if(ddBean == null) { 95 throw new IllegalArgumentException ("DDBean parameter cannot be null."); 96 } 97 ((SunONEDeploymentConfiguration)config).ensureResourceDefinedForEjb(ddBean, jndiName); 98 } 99 100 101 104 public void setMappingInfo(DeploymentConfiguration config, OriginalCMPMapping[] mapping){ 105 checkConfiguration(config); 106 SunONEDeploymentConfiguration s1config = (SunONEDeploymentConfiguration) config; 107 EjbJarRoot ejbJarRoot = s1config.getEjbJarRoot(); 108 if(ejbJarRoot != null) { 109 ejbJarRoot.mapCmpBeans(mapping); 110 } 111 } 112 113 114 117 public String getWebContextRoot(DeploymentConfiguration config, DeployableObject deplObj) throws ConfigurationException { 118 checkConfiguration(config); 119 assert config.getDeployableObject() == deplObj; 120 return ((SunONEDeploymentConfiguration)config).getContextRoot(); 121 } 122 123 124 127 public void setWebContextRoot(DeploymentConfiguration config, DeployableObject deplObj, String contextRoot) throws ConfigurationException { 128 checkConfiguration(config); 129 assert config.getDeployableObject() == deplObj; 130 ((SunONEDeploymentConfiguration)config).setContextRoot(contextRoot); 131 } 132 133 134 136 public void updateResourceDir(DeploymentConfiguration config, File resourceDir) { 137 checkConfiguration(config); 138 ((SunONEDeploymentConfiguration) config).updateResourceDir(resourceDir); 139 } 140 141 144 private void checkConfiguration(DeploymentConfiguration config) { 145 if(config == null) { 146 throw new IllegalArgumentException ("DeploymentConfiguration is null"); 147 } 148 if(!(config instanceof SunONEDeploymentConfiguration)) { 149 throw new IllegalArgumentException ("Wrong DeploymentConfiguration instance " + config.getClass().getName()); 150 } 151 } 152 153 159 public Set getDatasources(DeploymentConfiguration config) { 160 checkConfiguration(config); 161 SunONEDeploymentConfiguration sunConfig = ((SunONEDeploymentConfiguration)config); 162 Set projectDS = sunConfig.getDatasources(); 163 return projectDS; 164 } 165 166 170 public boolean isDatasourceCreationSupported() { 171 return true; 172 } 173 174 175 186 public Datasource createDatasource(DeploymentConfiguration config, String jndiName, String url, String username, String password, String driver) 187 throws OperationUnsupportedException , ConfigurationException , DatasourceAlreadyExistsException { 188 checkConfiguration(config); 189 SunONEDeploymentConfiguration sunConfig = ((SunONEDeploymentConfiguration)config); 190 return sunConfig.createDatasource(jndiName, url, username, password, driver); 191 } 192 193 } 194 195 | Popular Tags |