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 JmsService 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 JMS_HOST = "JmsHost"; 50 static public final String ELEMENT_PROPERTY = "ElementProperty"; 51 52 public JmsService() { 53 this(Common.USE_DEFAULT_VALUES); 54 } 55 56 public JmsService(int options) 57 { 58 super(comparators, runtimeVersion); 59 initPropertyTables(2); 61 this.createProperty("jms-host", JMS_HOST, 62 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 63 JmsHost.class); 64 this.createAttribute(JMS_HOST, "name", "Name", 65 AttrProp.CDATA | AttrProp.REQUIRED, 66 null, null); 67 this.createAttribute(JMS_HOST, "host", "Host", 68 AttrProp.CDATA | AttrProp.IMPLIED, 69 null, null); 70 this.createAttribute(JMS_HOST, "port", "Port", 71 AttrProp.CDATA, 72 null, "7676"); 73 this.createAttribute(JMS_HOST, "admin-user-name", "AdminUserName", 74 AttrProp.CDATA, 75 null, "admin"); 76 this.createAttribute(JMS_HOST, "admin-password", "AdminPassword", 77 AttrProp.CDATA, 78 null, "admin"); 79 this.createProperty("property", ELEMENT_PROPERTY, 80 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 81 ElementProperty.class); 82 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 83 AttrProp.CDATA | AttrProp.REQUIRED, 84 null, null); 85 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 86 AttrProp.CDATA | AttrProp.REQUIRED, 87 null, null); 88 this.initialize(options); 89 } 90 91 void initialize(int options) { 93 94 } 95 96 public void setJmsHost(int index, JmsHost value) { 98 this.setValue(JMS_HOST, index, value); 99 } 100 101 public JmsHost getJmsHost(int index) { 103 return (JmsHost)this.getValue(JMS_HOST, index); 104 } 105 106 public void setJmsHost(JmsHost[] value) { 108 this.setValue(JMS_HOST, value); 109 } 110 111 public JmsHost[] getJmsHost() { 113 return (JmsHost[])this.getValues(JMS_HOST); 114 } 115 116 public int sizeJmsHost() { 118 return this.size(JMS_HOST); 119 } 120 121 public int addJmsHost(JmsHost value) 123 throws ConfigException{ 124 return addJmsHost(value, true); 125 } 126 127 public int addJmsHost(JmsHost value, boolean overwrite) 129 throws ConfigException{ 130 JmsHost old = getJmsHostByName(value.getName()); 131 if(old != null) { 132 throw new ConfigException(StringManager.getManager(JmsService.class).getString("cannotAddDuplicate", "JmsHost")); 133 } 134 return this.addValue(JMS_HOST, value, overwrite); 135 } 136 137 public int removeJmsHost(JmsHost value){ 142 return this.removeValue(JMS_HOST, value); 143 } 144 145 public int removeJmsHost(JmsHost value, boolean overwrite) 151 throws StaleWriteConfigException{ 152 return this.removeValue(JMS_HOST, value, overwrite); 153 } 154 155 public JmsHost getJmsHostByName(String id) { 156 if (null != id) { id = id.trim(); } 157 JmsHost[] o = getJmsHost(); 158 if (o == null) return null; 159 160 for (int i=0; i < o.length; i++) { 161 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 162 return o[i]; 163 } 164 } 165 166 return null; 167 168 } 169 public void setElementProperty(int index, ElementProperty value) { 171 this.setValue(ELEMENT_PROPERTY, index, value); 172 } 173 174 public ElementProperty getElementProperty(int index) { 176 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 177 } 178 179 public void setElementProperty(ElementProperty[] value) { 181 this.setValue(ELEMENT_PROPERTY, value); 182 } 183 184 public ElementProperty[] getElementProperty() { 186 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 187 } 188 189 public int sizeElementProperty() { 191 return this.size(ELEMENT_PROPERTY); 192 } 193 194 public int addElementProperty(ElementProperty value) 196 throws ConfigException{ 197 return addElementProperty(value, true); 198 } 199 200 public int addElementProperty(ElementProperty value, boolean overwrite) 202 throws ConfigException{ 203 ElementProperty old = getElementPropertyByName(value.getName()); 204 if(old != null) { 205 throw new ConfigException(StringManager.getManager(JmsService.class).getString("cannotAddDuplicate", "ElementProperty")); 206 } 207 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 208 } 209 210 public int removeElementProperty(ElementProperty value){ 215 return this.removeValue(ELEMENT_PROPERTY, value); 216 } 217 218 public int removeElementProperty(ElementProperty value, boolean overwrite) 224 throws StaleWriteConfigException{ 225 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 226 } 227 228 public ElementProperty getElementPropertyByName(String id) { 229 if (null != id) { id = id.trim(); } 230 ElementProperty[] o = getElementProperty(); 231 if (o == null) return null; 232 233 for (int i=0; i < o.length; i++) { 234 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 235 return o[i]; 236 } 237 } 238 239 return null; 240 241 } 242 246 public String getInitTimeoutInSeconds() { 247 return getAttributeValue(ServerTags.INIT_TIMEOUT_IN_SECONDS); 248 } 249 254 public void setInitTimeoutInSeconds(String v, boolean overwrite) throws StaleWriteConfigException { 255 setAttributeValue(ServerTags.INIT_TIMEOUT_IN_SECONDS, v, overwrite); 256 } 257 261 public void setInitTimeoutInSeconds(String v) { 262 setAttributeValue(ServerTags.INIT_TIMEOUT_IN_SECONDS, v); 263 } 264 267 public static String getDefaultInitTimeoutInSeconds() { 268 return "60".trim(); 269 } 270 274 public String getType() { 275 return getAttributeValue(ServerTags.TYPE); 276 } 277 282 public void setType(String v, boolean overwrite) throws StaleWriteConfigException { 283 setAttributeValue(ServerTags.TYPE, v, overwrite); 284 } 285 289 public void setType(String v) { 290 setAttributeValue(ServerTags.TYPE, v); 291 } 292 296 public String getStartArgs() { 297 return getAttributeValue(ServerTags.START_ARGS); 298 } 299 304 public void setStartArgs(String v, boolean overwrite) throws StaleWriteConfigException { 305 setAttributeValue(ServerTags.START_ARGS, v, overwrite); 306 } 307 311 public void setStartArgs(String v) { 312 setAttributeValue(ServerTags.START_ARGS, v); 313 } 314 318 public String getDefaultJmsHost() { 319 return getAttributeValue(ServerTags.DEFAULT_JMS_HOST); 320 } 321 326 public void setDefaultJmsHost(String v, boolean overwrite) throws StaleWriteConfigException { 327 setAttributeValue(ServerTags.DEFAULT_JMS_HOST, v, overwrite); 328 } 329 333 public void setDefaultJmsHost(String v) { 334 setAttributeValue(ServerTags.DEFAULT_JMS_HOST, v); 335 } 336 340 public String getReconnectIntervalInSeconds() { 341 return getAttributeValue(ServerTags.RECONNECT_INTERVAL_IN_SECONDS); 342 } 343 348 public void setReconnectIntervalInSeconds(String v, boolean overwrite) throws StaleWriteConfigException { 349 setAttributeValue(ServerTags.RECONNECT_INTERVAL_IN_SECONDS, v, overwrite); 350 } 351 355 public void setReconnectIntervalInSeconds(String v) { 356 setAttributeValue(ServerTags.RECONNECT_INTERVAL_IN_SECONDS, v); 357 } 358 361 public static String getDefaultReconnectIntervalInSeconds() { 362 return "5".trim(); 363 } 364 368 public String getReconnectAttempts() { 369 return getAttributeValue(ServerTags.RECONNECT_ATTEMPTS); 370 } 371 376 public void setReconnectAttempts(String v, boolean overwrite) throws StaleWriteConfigException { 377 setAttributeValue(ServerTags.RECONNECT_ATTEMPTS, v, overwrite); 378 } 379 383 public void setReconnectAttempts(String v) { 384 setAttributeValue(ServerTags.RECONNECT_ATTEMPTS, v); 385 } 386 389 public static String getDefaultReconnectAttempts() { 390 return "3".trim(); 391 } 392 396 public boolean isReconnectEnabled() { 397 return toBoolean(getAttributeValue(ServerTags.RECONNECT_ENABLED)); 398 } 399 404 public void setReconnectEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 405 setAttributeValue(ServerTags.RECONNECT_ENABLED, ""+(v==true), overwrite); 406 } 407 411 public void setReconnectEnabled(boolean v) { 412 setAttributeValue(ServerTags.RECONNECT_ENABLED, ""+(v==true)); 413 } 414 417 public static String getDefaultReconnectEnabled() { 418 return "true".trim(); 419 } 420 424 public String getAddresslistBehavior() { 425 return getAttributeValue(ServerTags.ADDRESSLIST_BEHAVIOR); 426 } 427 432 public void setAddresslistBehavior(String v, boolean overwrite) throws StaleWriteConfigException { 433 setAttributeValue(ServerTags.ADDRESSLIST_BEHAVIOR, v, overwrite); 434 } 435 439 public void setAddresslistBehavior(String v) { 440 setAttributeValue(ServerTags.ADDRESSLIST_BEHAVIOR, v); 441 } 442 445 public static String getDefaultAddresslistBehavior() { 446 return "random".trim(); 447 } 448 452 public String getAddresslistIterations() { 453 return getAttributeValue(ServerTags.ADDRESSLIST_ITERATIONS); 454 } 455 460 public void setAddresslistIterations(String v, boolean overwrite) throws StaleWriteConfigException { 461 setAttributeValue(ServerTags.ADDRESSLIST_ITERATIONS, v, overwrite); 462 } 463 467 public void setAddresslistIterations(String v) { 468 setAttributeValue(ServerTags.ADDRESSLIST_ITERATIONS, v); 469 } 470 473 public static String getDefaultAddresslistIterations() { 474 return "3".trim(); 475 } 476 480 public String getMqScheme() { 481 return getAttributeValue(ServerTags.MQ_SCHEME); 482 } 483 488 public void setMqScheme(String v, boolean overwrite) throws StaleWriteConfigException { 489 setAttributeValue(ServerTags.MQ_SCHEME, v, overwrite); 490 } 491 495 public void setMqScheme(String v) { 496 setAttributeValue(ServerTags.MQ_SCHEME, v); 497 } 498 502 public String getMqService() { 503 return getAttributeValue(ServerTags.MQ_SERVICE); 504 } 505 510 public void setMqService(String v, boolean overwrite) throws StaleWriteConfigException { 511 setAttributeValue(ServerTags.MQ_SERVICE, v, overwrite); 512 } 513 517 public void setMqService(String v) { 518 setAttributeValue(ServerTags.MQ_SERVICE, v); 519 } 520 524 public JmsHost newJmsHost() { 525 return new JmsHost(); 526 } 527 528 532 public ElementProperty newElementProperty() { 533 return new ElementProperty(); 534 } 535 536 541 protected String getRelativeXPath() { 542 String ret = null; 543 ret = "jms-service"; 544 return (null != ret ? ret.trim() : null); 545 } 546 547 550 public static String getDefaultAttributeValue(String attr) { 551 if(attr == null) return null; 552 attr = attr.trim(); 553 if(attr.equals(ServerTags.INIT_TIMEOUT_IN_SECONDS)) return "60".trim(); 554 if(attr.equals(ServerTags.RECONNECT_INTERVAL_IN_SECONDS)) return "5".trim(); 555 if(attr.equals(ServerTags.RECONNECT_ATTEMPTS)) return "3".trim(); 556 if(attr.equals(ServerTags.RECONNECT_ENABLED)) return "true".trim(); 557 if(attr.equals(ServerTags.ADDRESSLIST_BEHAVIOR)) return "random".trim(); 558 if(attr.equals(ServerTags.ADDRESSLIST_ITERATIONS)) return "3".trim(); 559 return null; 560 } 561 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 563 comparators.add(c); 564 } 565 566 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 568 comparators.remove(c); 569 } 570 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 571 } 572 573 public void dump(StringBuffer str, String indent){ 575 String s; 576 Object o; 577 org.netbeans.modules.schema2beans.BaseBean n; 578 str.append(indent); 579 str.append("JmsHost["+this.sizeJmsHost()+"]"); for(int i=0; i<this.sizeJmsHost(); i++) 581 { 582 str.append(indent+"\t"); 583 str.append("#"+i+":"); 584 n = (org.netbeans.modules.schema2beans.BaseBean) this.getJmsHost(i); 585 if (n != null) 586 n.dump(str, indent + "\t"); else 588 str.append(indent+"\tnull"); this.dumpAttributes(JMS_HOST, i, str, indent); 590 } 591 592 str.append(indent); 593 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 595 { 596 str.append(indent+"\t"); 597 str.append("#"+i+":"); 598 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 599 if (n != null) 600 n.dump(str, indent + "\t"); else 602 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 604 } 605 606 } 607 public String dumpBeanNode(){ 608 StringBuffer str = new StringBuffer (); 609 str.append("JmsService\n"); this.dump(str, "\n "); return str.toString(); 612 }} 613 614 616 | Popular Tags |