1 5 package xdoclet.modules.sun.sunone.ejb; 6 7 import org.apache.commons.logging.Log; 8 9 import xdoclet.XDocletException; 10 import xdoclet.XDocletMessages; 11 import xdoclet.modules.ejb.dd.AbstractEjbDeploymentDescriptorSubTask; 12 import xdoclet.util.LogUtil; 13 import xdoclet.util.Translator; 14 15 41 public class SunONESubTask extends AbstractEjbDeploymentDescriptorSubTask 42 { 43 46 private final static String DEFAULT_TEMPLATE_FILE_70 = "resources/sun-ejb-jar_xml.xdt"; 47 private final static String DEFAULT_TEMPLATE_FILE_60 = "resources/ias-ejb-jar_xml.xdt"; 48 49 52 private final static String GENERATED_FILE_NAME_70 = "sun-ejb-jar.xml"; 53 private final static String GENERATED_FILE_NAME_60 = "ias-ejb-jar.xml"; 54 55 58 private final static String SUNONE_DD_PUBLICID_70 = "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 EJB 2.0//EN"; 59 private final static String SUNONE_DD_PUBLICID_60 = "-//Sun Microsystems, Inc.//DTD iAS Enterprise JavaBeans 1.0//EN"; 60 private final static String SUNONE_DD_PUBLICID_61 = "-//Sun Microsystems, Inc.//DTD iAS Enterprise JavaBeans 1.1//EN"; 61 62 65 private final static String SUNONE_DD_SYSTEMID_70 = "http://www.sun.com/software/sunone/appserver/dtds/sun-ejb-jar_2_0-0.dtd"; 66 private final static String SUNONE_DD_SYSTEMID_60 = "http://developer.iplanet.com/appserver/dtds/IASEjb_jar_1_0.dtd"; 67 private final static String SUNONE_DD_SYSTEMID_61 = "http://developer.iplanet.com/appserver/dtds/IASEjb_jar_1_1.dtd"; 68 69 72 private final static String SUNONE_DD_DTD_FILE_NAME_70 = "resources/sun-ejb-jar_2_0-0.dtd"; 73 private final static String SUNONE_DD_DTD_FILE_NAME_60 = "resources/IASEjb_jar_1_0.dtd"; 74 private final static String SUNONE_DD_DTD_FILE_NAME_61 = "resources/IASEjb_jar_1_1.dtd"; 75 76 79 private final static String DEFAULT_CMP_TEMPLATE_FILE_70 = "resources/sun-cmp-mappings_xml.xdt"; 80 81 84 private final static String GENERATED_CMP_FILE_NAME_70 = "sun-cmp-mappings.xml"; 85 private final static String GENERATED_CMP_FILE_NAME_60 = "???"; 86 90 93 private final static String SUNONE_CMP_PUBLICID_70 = "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 OR Mapping //EN"; 94 95 98 private final static String SUNONE_CMP_SYSTEMID_70 = "http://www.sun.com/software/sunone/appserver/dtds/sun-cmp-mapping_1_0.dtd"; 99 private final static String SUNONE_CMP_SYSTEMID_60 = "http://developer.iplanet.com/appserver/dtds/IASPersistence_manager_1_0.dtd"; 100 101 104 private final static String SUNONE_CMP_FILE_NAME_70 = "resources/sun-cmp-mapping_1_0.dtd"; 105 private final static String SUNONE_CMP_FILE_NAME_60 = "resources/IASPersistence_manager_1_0.dtd"; 106 107 110 private String version = SunONEVersionTypes.VERSION_7_0; 111 112 115 private String transactionManagerType = null; 116 117 120 private String cmpResourceJndiName = null; 121 122 125 private String cmpResourcePrincipalName = null; 126 127 130 private String cmpResourcePrincipalPassword = null; 131 132 135 private String cmpSchema = null; 136 137 private String cmpTemplateFile = null; 138 139 private String cmpDestinationFile = null; 140 141 public SunONESubTask() 142 { 143 setValidateXML(true); 144 } 145 146 151 public String getVersion() 152 { 153 return version; 154 } 155 156 161 public String getTransactionManagerType() 162 { 163 return transactionManagerType; 164 } 165 166 171 public String getCmpResourceJndiName() 172 { 173 return cmpResourceJndiName; 174 } 175 176 181 public String getCmpResourcePrincipalName() 182 { 183 return cmpResourcePrincipalName; 184 } 185 186 191 public String getCmpResourcePrincipalPassword() 192 { 193 return cmpResourcePrincipalPassword; 194 } 195 196 201 public String getCmpSchema() 202 { 203 return cmpSchema; 204 } 205 206 211 public String getCmpTemplateFile() 212 { 213 return cmpTemplateFile; 214 } 215 216 221 public String getCmpDestinationFile() 222 { 223 return cmpDestinationFile; 224 } 225 226 232 public void setVersion(SunONEVersionTypes version) 233 { 234 this.version = version.getValue(); 235 } 236 237 243 public void setTransactionManagerType(String transactionManagerType) 244 { 245 this.transactionManagerType = transactionManagerType; 246 } 247 248 254 public void setCmpResourceJndiName(String cmpResourceJndiName) 255 { 256 this.cmpResourceJndiName = cmpResourceJndiName; 257 } 258 259 265 public void setCmpResourcePrincipalName(String cmpResourcePrincipalName) 266 { 267 this.cmpResourcePrincipalName = cmpResourcePrincipalName; 268 } 269 270 276 public void setCmpResourcePrincipalPassword(String cmpResourcePrincipalPassword) 277 { 278 this.cmpResourcePrincipalPassword = cmpResourcePrincipalPassword; 279 } 280 281 287 public void setCmpSchema(String cmpSchema) 288 { 289 this.cmpSchema = cmpSchema; 290 } 291 292 298 public void setCmpTemplateFile(String cmpTemplateFile) 299 { 300 this.cmpTemplateFile = cmpTemplateFile; 301 } 302 303 309 public void setCmpDestinationFile(String cmpDestinationFile) 310 { 311 this.cmpDestinationFile = cmpDestinationFile; 312 } 313 314 319 public void validateOptions() throws XDocletException 320 { 321 324 if (getVersion().equals(SunONEVersionTypes.VERSION_6_5) 325 && getTransactionManagerType() != null) { 326 if (!getTransactionManagerType().equals("local") 327 && !getTransactionManagerType().equals("global")) { 328 throw new XDocletException(Translator.getString(XDocletModulesSunONEEjbMessages.class, 329 XDocletModulesSunONEEjbMessages.INVALID_TRANSACTION_MANAGER_TYPE)); 330 } 331 } 332 } 333 334 public void execute() throws XDocletException 335 { 336 if (getVersion().equals(SunONEVersionTypes.VERSION_6_0)) { 337 if (getTemplateURL() == null) 338 setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE_60)); 339 if (getDestinationFile() == null) 340 setDestinationFile(GENERATED_FILE_NAME_60); 341 if (getPublicId() == null) 342 setPublicId(SUNONE_DD_PUBLICID_60); 343 if (getSystemId() == null) 344 setSystemId(SUNONE_DD_SYSTEMID_60); 345 if (getDtdURL() == null) 346 setDtdURL(getClass().getResource(SUNONE_DD_DTD_FILE_NAME_60)); 347 } 348 else if (getVersion().equals(SunONEVersionTypes.VERSION_6_5)) { 349 if (getTemplateURL() == null) 350 setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE_60)); 351 if (getDestinationFile() == null) 352 setDestinationFile(GENERATED_FILE_NAME_60); 353 if (getPublicId() == null) 354 setPublicId(SUNONE_DD_PUBLICID_61); 355 if (getSystemId() == null) 356 setSystemId(SUNONE_DD_SYSTEMID_61); 357 if (getDtdURL() == null) 358 setDtdURL(getClass().getResource(SUNONE_DD_DTD_FILE_NAME_61)); 359 } 360 else if (getVersion().equals(SunONEVersionTypes.VERSION_7_0)) { 361 if (getTemplateURL() == null) 362 setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE_70)); 363 if (getDestinationFile() == null) 364 setDestinationFile(GENERATED_FILE_NAME_70); 365 if (getPublicId() == null) 366 setPublicId(SUNONE_DD_PUBLICID_70); 367 if (getSystemId() == null) 368 setSystemId(SUNONE_DD_SYSTEMID_70); 369 if (getDtdURL() == null) 370 setDtdURL(getClass().getResource(SUNONE_DD_DTD_FILE_NAME_70)); 371 } 372 startProcess(); 373 374 if (atLeastOneCmpEntityBeanExists()) { 375 if (getVersion().equals(SunONEVersionTypes.VERSION_7_0)) { 376 if (getCmpTemplateFile() != null) { 377 setTemplateURL(getClass().getResource(getCmpTemplateFile())); 378 } 379 else { 380 setTemplateURL(getClass().getResource(DEFAULT_CMP_TEMPLATE_FILE_70)); 381 } 382 if (getCmpDestinationFile() != null) { 383 setDestinationFile(getCmpDestinationFile()); 384 } 385 else { 386 setDestinationFile(GENERATED_CMP_FILE_NAME_70); 387 } 388 setPublicId(SUNONE_CMP_PUBLICID_70); 389 setSystemId(SUNONE_CMP_SYSTEMID_70); 390 setDtdURL(getClass().getResource(SUNONE_CMP_FILE_NAME_70)); 391 392 startProcess(); 393 } 394 } 395 } 396 397 400 public static class SunONEVersionTypes extends org.apache.tools.ant.types.EnumeratedAttribute 401 { 402 public final static String VERSION_6_0 = "6.0"; 403 public final static String VERSION_6_5 = "6.5"; 404 public final static String VERSION_7_0 = "7.0"; 405 406 411 public String [] getValues() 412 { 413 return (new String []{VERSION_6_0, VERSION_6_5, VERSION_7_0}); 414 } 415 } 416 417 } 418 | Popular Tags |