1 5 package xdoclet.modules.web; 6 7 import java.util.ArrayList ; 8 9 import xdoclet.XDocletException; 10 import xdoclet.XDocletMessages; 11 import xdoclet.XmlSubTask; 12 import xdoclet.util.Translator; 13 14 71 public class WebXmlSubTask extends XmlSubTask 72 { 73 private final static String DEFAULT_TEMPLATE_FILE = "resources/web_xml.xdt"; 74 75 private final static String GENERATED_FILE_NAME = "web.xml"; 76 77 private final static String WEBXML_PUBLICID_2_4 = "http://java.sun.com/xml/ns/j2ee"; 78 80 private final static String WEBXML_PUBLICID_2_3 = "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"; 81 82 private final static String WEBXML_PUBLICID_2_2 = "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"; 83 84 private final static String WEBXML_SYSTEMID_2_4 = "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; 85 87 private final static String WEBXML_SYSTEMID_2_3 = "http://java.sun.com/dtd/web-app_2_3.dtd"; 88 89 private final static String WEBXML_SYSTEMID_2_2 = "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"; 90 91 private final static String WEBXML_XSD_FILE_NAME_2_4 = "resources/web-app_2_4.xsd"; 92 93 private final static String WEBXML_DTD_FILE_NAME_2_3 = "resources/web-jar-23.dtd"; 94 95 private final static String WEBXML_DTD_FILE_NAME_2_2 = "resources/web-jar-22.dtd"; 96 97 private final static String XSD_LOCATION_24 = "http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; 98 99 protected String servletSpec = ServletVersionTypes.VERSION_2_3; 100 101 protected String smallIcon = ""; 102 103 protected String largeIcon = ""; 104 105 protected String displayName = ""; 106 107 protected String description = ""; 108 109 protected boolean distributable = true; 110 111 protected ArrayList contextParams = new ArrayList (); 112 113 protected Integer sessionTimeout = null; 114 115 117 protected ArrayList welcomeFiles = new ArrayList (); 118 119 protected ArrayList tagLibs = new ArrayList (); 120 121 124 public WebXmlSubTask() 125 { 126 setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE)); 127 setDestinationFile(GENERATED_FILE_NAME); 128 } 129 130 135 public String getServletspec() 136 { 137 return servletSpec; 138 } 139 140 145 public ArrayList getContextParams() 146 { 147 return contextParams; 148 } 149 150 155 public String getSmallicon() 156 { 157 return smallIcon; 158 } 159 160 165 public String getLargeicon() 166 { 167 return largeIcon; 168 } 169 170 175 public String getDisplayname() 176 { 177 return displayName; 178 } 179 180 185 public String getDescription() 186 { 187 return description; 188 } 189 190 195 public boolean getDistributable() 196 { 197 return distributable; 198 } 199 200 205 public Integer getSessiontimeout() 206 { 207 return sessionTimeout; 208 } 209 210 215 public ArrayList getWelcomeFiles() 216 { 217 return welcomeFiles; 218 } 219 220 225 public ArrayList getTagLibs() 226 { 227 return tagLibs; 228 } 229 230 235 public void setServletspec(ServletVersionTypes servletSpec) 236 { 237 this.servletSpec = servletSpec.getValue(); 238 } 239 240 246 public void setSmallicon(String smallIcon) 247 { 248 this.smallIcon = smallIcon; 249 } 250 251 257 public void setLargeicon(String largeIcon) 258 { 259 this.largeIcon = largeIcon; 260 } 261 262 267 public void setDisplayname(String displayName) 268 { 269 this.displayName = displayName; 270 } 271 272 277 public void setDescription(String description) 278 { 279 this.description = description; 280 } 281 282 288 public void setDistributable(boolean distributable) 289 { 290 this.distributable = distributable; 291 } 292 293 300 public void setSessiontimeout(Integer session_timeout) 301 { 302 sessionTimeout = session_timeout; 303 } 304 305 311 public void setTagLibs(ArrayList tagLibs) 312 { 313 this.tagLibs = tagLibs; 314 } 315 316 322 public void setWelcomeFiles(ArrayList welcomeFiles) 323 { 324 this.welcomeFiles = welcomeFiles; 325 } 326 327 333 public void setContextParams(ArrayList contextParams) 334 { 335 this.contextParams = contextParams; 336 } 337 338 343 public void addConfiguredContextparam(ContextParam cp) 344 { 345 contextParams.add(cp); 346 } 347 348 353 public void addConfiguredWelcomefile(WelcomeFile file) 354 { 355 welcomeFiles.add(file); 356 } 357 358 363 public void addConfiguredTaglib(TagLib taglib) 364 { 365 tagLibs.add(taglib); 366 } 367 368 373 public void execute() throws XDocletException 374 { 375 if (getServletspec().equals("2.2")) { 376 setPublicId(WEBXML_PUBLICID_2_2); 377 setSystemId(WEBXML_SYSTEMID_2_2); 378 setDtdURL(getClass().getResource(WEBXML_DTD_FILE_NAME_2_2)); 379 } 380 else if (getServletspec().equals("2.4")) { 381 setSchema(XSD_LOCATION_24); 382 setSchemaURL(getClass().getResource(WEBXML_XSD_FILE_NAME_2_4)); 383 } 384 else { 385 setPublicId(WEBXML_PUBLICID_2_3); 386 setSystemId(WEBXML_SYSTEMID_2_3); 387 setDtdURL(getClass().getResource(WEBXML_DTD_FILE_NAME_2_3)); 388 } 389 390 startProcess(); 391 } 392 393 398 protected void engineStarted() throws XDocletException 399 { 400 System.out.println(Translator.getString(XDocletMessages.class, XDocletMessages.GENERATING_SOMETHING, new String []{getDestinationFile()})); 401 } 402 403 409 public static class ContextParam implements java.io.Serializable 410 { 411 private String paramName = null; 412 413 private String paramValue = null; 414 415 private String description = ""; 416 417 422 public String getName() 423 { 424 return paramName; 425 } 426 427 432 public String getValue() 433 { 434 return paramValue; 435 } 436 437 442 public String getDescription() 443 { 444 return description; 445 } 446 447 452 public void setName(String name) 453 { 454 paramName = name; 455 } 456 457 462 public void setValue(String value) 463 { 464 paramValue = value; 465 } 466 467 472 public void setDescription(String desc) 473 { 474 description = desc; 475 } 476 } 477 478 484 public static class TagLib implements java.io.Serializable 485 { 486 private String taglibUri = null; 487 488 private String taglibLocation = null; 489 490 495 public String getUri() 496 { 497 return taglibUri; 498 } 499 500 501 506 public String getLocation() 507 { 508 return taglibLocation; 509 } 510 511 517 public void setUri(String uri) 518 { 519 taglibUri = uri; 520 } 521 522 528 public void setLocation(String location) 529 { 530 taglibLocation = location; 531 } 532 } 533 534 540 public static class WelcomeFile implements java.io.Serializable 541 { 542 private String file = null; 543 544 549 public String getFile() 550 { 551 return file; 552 } 553 554 559 public void setFile(String file) 560 { 561 this.file = file; 562 } 563 } 564 565 571 public static class ServletVersionTypes extends org.apache.tools.ant.types.EnumeratedAttribute 572 { 573 public final static String VERSION_2_2 = "2.2"; 574 public final static String VERSION_2_3 = "2.3"; 575 public final static String VERSION_2_4 = "2.4"; 576 577 582 public String [] getValues() 583 { 584 return (new String []{VERSION_2_2, VERSION_2_3, VERSION_2_4}); 585 } 586 } 587 } 588 | Popular Tags |