1 23 24 28 29 package com.sun.enterprise.config.serverbeans; 30 31 import org.w3c.dom.*; 32 import org.netbeans.modules.schema2beans.*; 33 import java.beans.*; 34 import java.util.*; 35 import java.io.Serializable ; 36 import com.sun.enterprise.config.ConfigBean; 37 import com.sun.enterprise.config.ConfigException; 38 import com.sun.enterprise.config.StaleWriteConfigException; 39 import com.sun.enterprise.util.i18n.StringManager; 40 41 43 public class HttpListener extends ConfigBean implements Serializable 44 { 45 46 static Vector comparators = new Vector(); 47 private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(4, 2, 0); 48 49 static public final String SSL = "Ssl"; 50 static public final String ELEMENT_PROPERTY = "ElementProperty"; 51 52 public HttpListener() { 53 this(Common.USE_DEFAULT_VALUES); 54 } 55 56 public HttpListener(int options) 57 { 58 super(comparators, runtimeVersion); 59 initPropertyTables(2); 61 this.createProperty("ssl", SSL, 62 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 63 Ssl.class); 64 this.createAttribute(SSL, "cert-nickname", "CertNickname", 65 AttrProp.CDATA | AttrProp.REQUIRED, 66 null, null); 67 this.createAttribute(SSL, "ssl2-enabled", "Ssl2Enabled", 68 AttrProp.CDATA, 69 null, "false"); 70 this.createAttribute(SSL, "ssl2-ciphers", "Ssl2Ciphers", 71 AttrProp.CDATA | AttrProp.IMPLIED, 72 null, null); 73 this.createAttribute(SSL, "ssl3-enabled", "Ssl3Enabled", 74 AttrProp.CDATA, 75 null, "true"); 76 this.createAttribute(SSL, "ssl3-tls-ciphers", "Ssl3TlsCiphers", 77 AttrProp.CDATA | AttrProp.IMPLIED, 78 null, null); 79 this.createAttribute(SSL, "tls-enabled", "TlsEnabled", 80 AttrProp.CDATA, 81 null, "true"); 82 this.createAttribute(SSL, "tls-rollback-enabled", "TlsRollbackEnabled", 83 AttrProp.CDATA, 84 null, "true"); 85 this.createAttribute(SSL, "client-auth-enabled", "ClientAuthEnabled", 86 AttrProp.CDATA, 87 null, "false"); 88 this.createProperty("property", ELEMENT_PROPERTY, 89 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 90 ElementProperty.class); 91 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 92 AttrProp.CDATA | AttrProp.REQUIRED, 93 null, null); 94 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 95 AttrProp.CDATA | AttrProp.REQUIRED, 96 null, null); 97 this.initialize(options); 98 } 99 100 void initialize(int options) { 102 103 } 104 105 public void setSsl(Ssl value) { 107 this.setValue(SSL, value); 108 } 109 110 public Ssl getSsl() { 112 return (Ssl)this.getValue(SSL); 113 } 114 115 public void setElementProperty(int index, ElementProperty value) { 117 this.setValue(ELEMENT_PROPERTY, index, value); 118 } 119 120 public ElementProperty getElementProperty(int index) { 122 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 123 } 124 125 public void setElementProperty(ElementProperty[] value) { 127 this.setValue(ELEMENT_PROPERTY, value); 128 } 129 130 public ElementProperty[] getElementProperty() { 132 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 133 } 134 135 public int sizeElementProperty() { 137 return this.size(ELEMENT_PROPERTY); 138 } 139 140 public int addElementProperty(ElementProperty value) 142 throws ConfigException{ 143 return addElementProperty(value, true); 144 } 145 146 public int addElementProperty(ElementProperty value, boolean overwrite) 148 throws ConfigException{ 149 ElementProperty old = getElementPropertyByName(value.getName()); 150 if(old != null) { 151 throw new ConfigException(StringManager.getManager(HttpListener.class).getString("cannotAddDuplicate", "ElementProperty")); 152 } 153 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 154 } 155 156 public int removeElementProperty(ElementProperty value){ 161 return this.removeValue(ELEMENT_PROPERTY, value); 162 } 163 164 public int removeElementProperty(ElementProperty value, boolean overwrite) 170 throws StaleWriteConfigException{ 171 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 172 } 173 174 public ElementProperty getElementPropertyByName(String id) { 175 if (null != id) { id = id.trim(); } 176 ElementProperty[] o = getElementProperty(); 177 if (o == null) return null; 178 179 for (int i=0; i < o.length; i++) { 180 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 181 return o[i]; 182 } 183 } 184 185 return null; 186 187 } 188 192 public String getId() { 193 return getAttributeValue(ServerTags.ID); 194 } 195 200 public void setId(String v, boolean overwrite) throws StaleWriteConfigException { 201 setAttributeValue(ServerTags.ID, v, overwrite); 202 } 203 207 public void setId(String v) { 208 setAttributeValue(ServerTags.ID, v); 209 } 210 214 public String getAddress() { 215 return getAttributeValue(ServerTags.ADDRESS); 216 } 217 222 public void setAddress(String v, boolean overwrite) throws StaleWriteConfigException { 223 setAttributeValue(ServerTags.ADDRESS, v, overwrite); 224 } 225 229 public void setAddress(String v) { 230 setAttributeValue(ServerTags.ADDRESS, v); 231 } 232 236 public String getPort() { 237 return getAttributeValue(ServerTags.PORT); 238 } 239 244 public void setPort(String v, boolean overwrite) throws StaleWriteConfigException { 245 setAttributeValue(ServerTags.PORT, v, overwrite); 246 } 247 251 public void setPort(String v) { 252 setAttributeValue(ServerTags.PORT, v); 253 } 254 258 public String getExternalPort() { 259 return getAttributeValue(ServerTags.EXTERNAL_PORT); 260 } 261 266 public void setExternalPort(String v, boolean overwrite) throws StaleWriteConfigException { 267 setAttributeValue(ServerTags.EXTERNAL_PORT, v, overwrite); 268 } 269 273 public void setExternalPort(String v) { 274 setAttributeValue(ServerTags.EXTERNAL_PORT, v); 275 } 276 280 public String getFamily() { 281 return getAttributeValue(ServerTags.FAMILY); 282 } 283 288 public void setFamily(String v, boolean overwrite) throws StaleWriteConfigException { 289 setAttributeValue(ServerTags.FAMILY, v, overwrite); 290 } 291 295 public void setFamily(String v) { 296 setAttributeValue(ServerTags.FAMILY, v); 297 } 298 301 public static String getDefaultFamily() { 302 return "inet".trim(); 303 } 304 308 public boolean isBlockingEnabled() { 309 return toBoolean(getAttributeValue(ServerTags.BLOCKING_ENABLED)); 310 } 311 316 public void setBlockingEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 317 setAttributeValue(ServerTags.BLOCKING_ENABLED, ""+(v==true), overwrite); 318 } 319 323 public void setBlockingEnabled(boolean v) { 324 setAttributeValue(ServerTags.BLOCKING_ENABLED, ""+(v==true)); 325 } 326 329 public static String getDefaultBlockingEnabled() { 330 return "false".trim(); 331 } 332 336 public String getAcceptorThreads() { 337 return getAttributeValue(ServerTags.ACCEPTOR_THREADS); 338 } 339 344 public void setAcceptorThreads(String v, boolean overwrite) throws StaleWriteConfigException { 345 setAttributeValue(ServerTags.ACCEPTOR_THREADS, v, overwrite); 346 } 347 351 public void setAcceptorThreads(String v) { 352 setAttributeValue(ServerTags.ACCEPTOR_THREADS, v); 353 } 354 357 public static String getDefaultAcceptorThreads() { 358 return "1".trim(); 359 } 360 364 public boolean isSecurityEnabled() { 365 return toBoolean(getAttributeValue(ServerTags.SECURITY_ENABLED)); 366 } 367 372 public void setSecurityEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 373 setAttributeValue(ServerTags.SECURITY_ENABLED, ""+(v==true), overwrite); 374 } 375 379 public void setSecurityEnabled(boolean v) { 380 setAttributeValue(ServerTags.SECURITY_ENABLED, ""+(v==true)); 381 } 382 385 public static String getDefaultSecurityEnabled() { 386 return "false".trim(); 387 } 388 392 public String getDefaultVirtualServer() { 393 return getAttributeValue(ServerTags.DEFAULT_VIRTUAL_SERVER); 394 } 395 400 public void setDefaultVirtualServer(String v, boolean overwrite) throws StaleWriteConfigException { 401 setAttributeValue(ServerTags.DEFAULT_VIRTUAL_SERVER, v, overwrite); 402 } 403 407 public void setDefaultVirtualServer(String v) { 408 setAttributeValue(ServerTags.DEFAULT_VIRTUAL_SERVER, v); 409 } 410 414 public String getServerName() { 415 return getAttributeValue(ServerTags.SERVER_NAME); 416 } 417 422 public void setServerName(String v, boolean overwrite) throws StaleWriteConfigException { 423 setAttributeValue(ServerTags.SERVER_NAME, v, overwrite); 424 } 425 429 public void setServerName(String v) { 430 setAttributeValue(ServerTags.SERVER_NAME, v); 431 } 432 436 public String getRedirectPort() { 437 return getAttributeValue(ServerTags.REDIRECT_PORT); 438 } 439 444 public void setRedirectPort(String v, boolean overwrite) throws StaleWriteConfigException { 445 setAttributeValue(ServerTags.REDIRECT_PORT, v, overwrite); 446 } 447 451 public void setRedirectPort(String v) { 452 setAttributeValue(ServerTags.REDIRECT_PORT, v); 453 } 454 458 public boolean isXpoweredBy() { 459 return toBoolean(getAttributeValue(ServerTags.XPOWERED_BY)); 460 } 461 466 public void setXpoweredBy(boolean v, boolean overwrite) throws StaleWriteConfigException { 467 setAttributeValue(ServerTags.XPOWERED_BY, ""+(v==true), overwrite); 468 } 469 473 public void setXpoweredBy(boolean v) { 474 setAttributeValue(ServerTags.XPOWERED_BY, ""+(v==true)); 475 } 476 479 public static String getDefaultXpoweredBy() { 480 return "true".trim(); 481 } 482 486 public boolean isEnabled() { 487 return toBoolean(getAttributeValue(ServerTags.ENABLED)); 488 } 489 494 public void setEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 495 setAttributeValue(ServerTags.ENABLED, ""+(v==true), overwrite); 496 } 497 501 public void setEnabled(boolean v) { 502 setAttributeValue(ServerTags.ENABLED, ""+(v==true)); 503 } 504 507 public static String getDefaultEnabled() { 508 return "true".trim(); 509 } 510 514 public Ssl newSsl() { 515 return new Ssl(); 516 } 517 518 522 public ElementProperty newElementProperty() { 523 return new ElementProperty(); 524 } 525 526 531 protected String getRelativeXPath() { 532 String ret = null; 533 ret = "http-listener" + (canHaveSiblings() ? "[@id='" + getAttributeValue("id") +"']" : "") ; 534 return (null != ret ? ret.trim() : null); 535 } 536 537 540 public static String getDefaultAttributeValue(String attr) { 541 if(attr == null) return null; 542 attr = attr.trim(); 543 if(attr.equals(ServerTags.FAMILY)) return "inet".trim(); 544 if(attr.equals(ServerTags.BLOCKING_ENABLED)) return "false".trim(); 545 if(attr.equals(ServerTags.ACCEPTOR_THREADS)) return "1".trim(); 546 if(attr.equals(ServerTags.SECURITY_ENABLED)) return "false".trim(); 547 if(attr.equals(ServerTags.XPOWERED_BY)) return "true".trim(); 548 if(attr.equals(ServerTags.ENABLED)) return "true".trim(); 549 return null; 550 } 551 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 553 comparators.add(c); 554 } 555 556 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 558 comparators.remove(c); 559 } 560 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 561 } 562 563 public void dump(StringBuffer str, String indent){ 565 String s; 566 Object o; 567 org.netbeans.modules.schema2beans.BaseBean n; 568 str.append(indent); 569 str.append("Ssl"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getSsl(); 571 if (n != null) 572 n.dump(str, indent + "\t"); else 574 str.append(indent+"\tnull"); this.dumpAttributes(SSL, 0, str, indent); 576 577 str.append(indent); 578 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 580 { 581 str.append(indent+"\t"); 582 str.append("#"+i+":"); 583 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 584 if (n != null) 585 n.dump(str, indent + "\t"); else 587 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 589 } 590 591 } 592 public String dumpBeanNode(){ 593 StringBuffer str = new StringBuffer (); 594 str.append("HttpListener\n"); this.dump(str, "\n "); return str.toString(); 597 }} 598 599 601 | Popular Tags |