1 5 package xdoclet.modules.objectweb.jonas.ejb; 6 7 import org.apache.tools.ant.types.EnumeratedAttribute; 8 9 import xdoclet.XDocletException; 10 import xdoclet.modules.ejb.dd.AbstractEjbDeploymentDescriptorSubTask; 11 12 25 public class JonasSubTask extends AbstractEjbDeploymentDescriptorSubTask 26 { 27 30 private final static String DEFAULT_JONAS_DD_FILE_NAME = "jonas-ejb-jar.xml"; 31 32 35 private final static String DEFAULT_TEMPLATE_FILE = "resources/jonas.xdt"; 36 37 40 private final static String JONAS_DD_PUBLICID_2_3 41 = "-//ObjectWeb//DTD JOnAS 2.3//EN"; 42 43 46 private final static String JONAS_DD_SYSTEMID_2_3 47 = "@JONAS_ROOT@/xml/jonas-ejb-jar.dtd"; 48 49 52 private final static String JONAS_DTD_FILE_NAME_2_3 53 = "resources/jonas-ejb-jar_2_3.dtd"; 54 55 58 private final static String JONAS_DD_PUBLICID_2_4 59 = "-//ObjectWeb//DTD JOnAS 2.4//EN"; 60 61 64 private final static String JONAS_DD_SYSTEMID_2_4 65 = "http://www.objectweb.org/jonas/dtds/jonas-ejb-jar_2_4.dtd"; 66 67 70 private final static String JONAS_DTD_FILE_NAME_2_4 71 = "resources/jonas-ejb-jar_2_4.dtd"; 72 73 76 private final static String JONAS_DD_PUBLICID_2_5 77 = "-//ObjectWeb//DTD JOnAS 2.5//EN"; 78 79 82 private final static String JONAS_DD_SYSTEMID_2_5 83 = "http://www.objectweb.org/jonas/dtds/jonas-ejb-jar_2_5.dtd"; 84 85 88 private final static String JONAS_DTD_FILE_NAME_2_5 89 = "resources/jonas-ejb-jar_2_5.dtd"; 90 91 94 private final static String JONAS_DD_PUBLICID_3_0 95 = "-//ObjectWeb//DTD JOnAS 3.0//EN"; 96 97 100 private final static String JONAS_DD_SYSTEMID_3_0 101 = "http://www.objectweb.org/jonas/dtds/jonas-ejb-jar_3_0.dtd"; 102 103 106 private final static String JONAS_DTD_FILE_NAME_3_0 107 = "resources/jonas-ejb-jar_3_0.dtd"; 108 111 private final static String JONAS_DD_PUBLICID_3_2 112 = "-//ObjectWeb//DTD JOnAS 3.2//EN"; 113 114 117 private final static String JONAS_DD_SYSTEMID_3_2 118 = "http://www.objectweb.org/jonas/dtds/jonas-ejb-jar_3_2.dtd"; 119 120 123 private final static String JONAS_DTD_FILE_NAME_3_2 124 = "resources/jonas-ejb-jar_3_2.dtd"; 125 126 129 private final static String JONAS_DTD_FILE_NAME_3_3_2 130 = "resources/jonas-ejb-jar_3_3_2.dtd"; 131 132 135 private final static String JONAS_DD_PUBLICID_3_3_2 136 = "-//ObjectWeb//DTD JOnAS 3.3.2//EN"; 137 138 141 private final static String JONAS_DD_SYSTEMID_3_3_2 142 = "http://www.objectweb.org/jonas/dtds/jonas-ejb-jar_3_3_2.dtd"; 143 146 147 150 private final static String JONAS_DD_SYSTEMID_4_0 151 = "http://www.objectweb.org/jonas/ns/jonas-ejb-jar_4_0.xsd"; 152 153 156 private final static String JONAS_DTD_FILE_NAME_4_0 157 = "resources/jonas-ejb-jar_4_0.xsd"; 158 159 162 163 166 private final static String JONAS_DD_SYSTEMID_4_2 167 = "http://jonas.objectweb.org/ns/jonas-ejb-jar_4_2.xsd"; 168 169 172 private final static String JONAS_DTD_FILE_NAME_4_2 173 = "resources/jonas-ejb-jar_4_2.xsd"; 174 175 178 private String version = JonasVersionTypes.DEFAULT_VERSION; 179 180 183 private String defaultEntityJndiName; 184 185 188 public JonasSubTask() 189 { 190 super(); 191 setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE)); 192 setDestinationFile(DEFAULT_JONAS_DD_FILE_NAME); 193 } 194 195 200 public String getVersion() 201 { 202 return version; 203 } 204 205 210 public String getDefaultEntityJndiName() 211 { 212 return this.defaultEntityJndiName; 213 } 214 215 221 public void setVersion(JonasVersionTypes version) 222 { 223 this.version = version.getValue(); 224 } 225 226 231 public void setDefaultEntityJndiName(String defaultEntityJndiName) 232 { 233 this.defaultEntityJndiName = defaultEntityJndiName; 234 } 235 236 237 public void execute() throws XDocletException 238 { 239 if (getVersion().equals(JonasVersionTypes.VERSION_4_2)) { 240 if (getSystemId() == null) 241 setSystemId(JONAS_DD_SYSTEMID_4_2); 242 if (getDtdURL() == null) 243 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_4_2)); 244 } 245 if (getVersion().equals(JonasVersionTypes.VERSION_4_0)) { 246 if (getSystemId() == null) 247 setSystemId(JONAS_DD_SYSTEMID_4_0); 248 if (getDtdURL() == null) 249 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_4_0)); 250 } 251 else if (getVersion().equals(JonasVersionTypes.VERSION_3_3_2)) { 252 if (getPublicId() == null) 253 setPublicId(JONAS_DD_PUBLICID_3_3_2); 254 if (getSystemId() == null) 255 setSystemId(JONAS_DD_SYSTEMID_3_3_2); 256 if (getDtdURL() == null) 257 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_3_3_2)); 258 } 259 else if (getVersion().equals(JonasVersionTypes.VERSION_3_2)) { 260 if (getPublicId() == null) 261 setPublicId(JONAS_DD_PUBLICID_3_2); 262 if (getSystemId() == null) 263 setSystemId(JONAS_DD_SYSTEMID_3_2); 264 if (getDtdURL() == null) 265 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_3_2)); 266 } 267 else if (getVersion().equals(JonasVersionTypes.VERSION_3_0)) { 268 if (getPublicId() == null) 269 setPublicId(JONAS_DD_PUBLICID_3_0); 270 if (getSystemId() == null) 271 setSystemId(JONAS_DD_SYSTEMID_3_0); 272 if (getDtdURL() == null) 273 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_3_0)); 274 } 275 else if (getVersion().equals(JonasVersionTypes.VERSION_2_5) 276 || getVersion().equals(JonasVersionTypes.VERSION_2_6)) { 277 if (getPublicId() == null) 279 setPublicId(JONAS_DD_PUBLICID_2_5); 280 if (getSystemId() == null) 281 setSystemId(JONAS_DD_SYSTEMID_2_5); 282 if (getDtdURL() == null) 283 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_2_5)); 284 } 285 else if (getVersion().equals(JonasVersionTypes.VERSION_2_4)) { 286 if (getPublicId() == null) 287 setPublicId(JONAS_DD_PUBLICID_2_4); 288 if (getSystemId() == null) 289 setSystemId(JONAS_DD_SYSTEMID_2_4); 290 if (getDtdURL() == null) 291 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_2_4)); 292 } 293 else if (getVersion().equals(JonasVersionTypes.VERSION_2_3)) { 294 if (getPublicId() == null) 295 setPublicId(JONAS_DD_PUBLICID_2_3); 296 if (getSystemId() == null) 297 setSystemId(JONAS_DD_SYSTEMID_2_3); 298 if (getDtdURL() == null) 299 setDtdURL(getClass().getResource(JONAS_DTD_FILE_NAME_2_3)); 300 } 301 startProcess(); 302 } 303 304 306 312 public static class JonasVersionTypes extends EnumeratedAttribute 313 { 314 public final static String VERSION_2_3 = "2.3"; 315 public final static String VERSION_2_4 = "2.4"; 316 public final static String VERSION_2_5 = "2.5"; 317 public final static String VERSION_2_6 = "2.6"; 318 public final static String VERSION_3_0 = "3.0"; 319 public final static String VERSION_3_2 = "3.2"; 320 public final static String VERSION_3_3_2 = "3.3.2"; 321 public final static String VERSION_4_0 = "4.0"; 322 public final static String VERSION_4_2 = "4.2"; 323 public final static String DEFAULT_VERSION = VERSION_4_2; 324 325 330 public String [] getValues() 331 { 332 return (new String []{VERSION_2_3, VERSION_2_4, VERSION_2_5, VERSION_2_6, VERSION_3_0, VERSION_3_2, VERSION_3_3_2, VERSION_4_0, VERSION_4_2}); 333 } 334 } 335 336 } 337 | Popular Tags |