1 5 package xdoclet.modules.ibm.websphere.web; 6 7 import xdoclet.XDocletException; 8 9 import xdoclet.XmlSubTask; 10 import xdoclet.util.Translator; 11 12 45 public class WebSphereWebXmlSubTask extends XmlSubTask 46 { 47 50 private final static String TRUE = "true"; 51 52 55 private final static String FALSE = "false"; 56 57 61 private final static String 62 BINDINGS_TEMPLATE_FILE = "resources/ibm-web-bnd_xmi.xdt"; 63 64 67 private final static String 68 GENERATED_BINDINGS_FILE_NAME = "ibm-web-bnd.xmi"; 69 70 74 private final static String 75 EXTENSIONS_TEMPLATE_FILE = "resources/ibm-web-ext_xmi.xdt"; 76 77 80 private final static String 81 GENERATED_EXTENSIONS_FILE_NAME = "ibm-web-ext.xmi"; 82 83 86 private boolean hasTransformedWebXml = false; 87 88 91 private String virtualHostName = "default_host"; 92 93 96 private String reloadInterval = "3"; 97 98 101 private String reloadingEnabled = "true"; 102 103 106 private String defaultErrorPage = ""; 107 108 111 private String additionalClassPath = ""; 112 113 116 private String fileServingEnabled = "true"; 117 118 121 private String directoryBrowsingEnabled = "true"; 122 123 126 private String serveServletsByClassnameEnabled = "true"; 127 128 131 private String preCompileJSPs = "true"; 132 133 136 private String autoRequestEncoding = "false"; 137 138 141 private String autoResponseEncoding = "false"; 142 143 146 private String autoLoadFilters = "false"; 147 148 public WebSphereWebXmlSubTask() 149 { 150 setUseIds(true); 151 } 152 153 157 public String getVirtualHostName() 158 { 159 return virtualHostName; 160 } 161 162 166 public String getReloadInterval() 167 { 168 return reloadInterval; 169 } 170 171 175 public String getReloadingEnabled() 176 { 177 return reloadingEnabled; 178 } 179 180 184 public String getDefaultErrorPage() 185 { 186 return defaultErrorPage; 187 } 188 189 193 public String getAdditionalClassPath() 194 { 195 return additionalClassPath; 196 } 197 198 202 public String getFileServingEnabled() 203 { 204 return fileServingEnabled; 205 } 206 207 211 public String getDirectoryBrowsingEnabled() 212 { 213 return directoryBrowsingEnabled; 214 } 215 216 220 public String getServeServletsByClassnameEnabled() 221 { 222 return serveServletsByClassnameEnabled; 223 } 224 225 229 public String getPreCompileJSPs() 230 { 231 return preCompileJSPs; 232 } 233 234 238 public String getAutoRequestEncoding() 239 { 240 return autoRequestEncoding; 241 } 242 243 247 public String getAutoResponseEncoding() 248 { 249 return autoResponseEncoding; 250 } 251 252 256 public String getAutoLoadFilters() 257 { 258 return autoLoadFilters; 259 } 260 261 269 public void setVirtualHostName(String name) 270 { 271 virtualHostName = name; 272 } 273 274 282 public void setReloadInterval(String reloadInterval) 283 { 284 this.reloadInterval = validateIntegerValue(reloadInterval, "reloadInterval"); 285 } 286 287 293 public void setReloadingEnabled(String reloadingEnabled) 294 { 295 this.reloadingEnabled = reloadingEnabled; 296 } 297 298 305 public void setDefaultErrorPage(String defaultErrorPage) 306 { 307 this.defaultErrorPage = defaultErrorPage; 308 } 309 310 317 public void setAdditionalClassPath(String additionalClassPath) 318 { 319 this.additionalClassPath = additionalClassPath; 320 } 321 322 329 public void setFileServingEnabled(String fileServingEnabled) 330 { 331 this.fileServingEnabled = validateBooleanValue(fileServingEnabled, "fileServingEnabled"); 332 } 333 334 341 public void setDirectoryBrowsingEnabled(String directoryBrowsingEnabled) 342 { 343 this.directoryBrowsingEnabled = validateBooleanValue(directoryBrowsingEnabled, "directoryBrowsingEnabled"); 344 } 345 346 356 public void setServeServletsByClassnameEnabled(String serveServletsByClassnameEnabled) 357 { 358 this.serveServletsByClassnameEnabled = validateBooleanValue(serveServletsByClassnameEnabled, "serveServletsByClassnameEnabled"); 359 } 360 361 367 public void setPreCompileJSPs(String preCompileJSPs) 368 { 369 this.preCompileJSPs = validateBooleanValue(preCompileJSPs, "preCompileJSPs"); 370 } 371 372 378 public void setAutoRequestEncoding(String autoRequestEncoding) 379 { 380 this.autoRequestEncoding = validateBooleanValue(autoRequestEncoding, "autoRequestEncoding"); 381 } 382 383 389 public void setAutoResponseEncoding(String autoResponseEncoding) 390 { 391 this.autoResponseEncoding = validateBooleanValue(autoResponseEncoding, "autoResponseEncoding"); 392 } 393 394 400 public void setAutoLoadFilters(String autoLoadFilters) 401 { 402 this.autoLoadFilters = validateBooleanValue(autoLoadFilters, "autoLoadFilters"); 403 } 404 405 410 public void validateOptions() throws XDocletException 411 { 412 } 417 418 423 public void execute() throws XDocletException 424 { 425 setTemplateURL(getClass().getResource(BINDINGS_TEMPLATE_FILE)); 426 setDestinationFile(GENERATED_BINDINGS_FILE_NAME); 427 startProcess(); 428 429 setTemplateURL(getClass().getResource(EXTENSIONS_TEMPLATE_FILE)); 430 setDestinationFile(GENERATED_EXTENSIONS_FILE_NAME); 431 startProcess(); 432 } 433 434 439 protected void engineStarted() throws XDocletException 440 { 441 } 442 443 450 private String validateIntegerValue(String integerValue, String name) 451 { 452 try { 453 Integer.parseInt(integerValue); 454 } 455 catch (NumberFormatException e) { 456 throwInvalidConfigValueException(integerValue, name); 457 } 458 459 return integerValue; 460 } 461 462 469 private String validateBooleanValue(String booleanValue, String name) 470 { 471 if (booleanValue == null) { 472 booleanValue = ""; 473 } 474 475 if (!(TRUE.equals(booleanValue) || 476 FALSE.equals(booleanValue) || 477 "".equals(booleanValue))) { 478 throwInvalidConfigValueException(booleanValue, name); 479 } 480 481 return booleanValue; 482 } 483 484 490 private void throwInvalidConfigValueException(String value, String name) 491 { 492 throw new RuntimeException ( 493 Translator.getString( 494 XDocletModulesIbmWebsphereWebMessages.class, 495 XDocletModulesIbmWebsphereWebMessages.INVALID_CONFIG_VALUE, 496 new String []{value, name})); 497 } 498 } 499 | Popular Tags |