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 ConnectorConnectionPool 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 DESCRIPTION = "Description"; 50 static public final String SECURITY_MAP = "SecurityMap"; 51 static public final String ELEMENT_PROPERTY = "ElementProperty"; 52 53 public ConnectorConnectionPool() { 54 this(Common.USE_DEFAULT_VALUES); 55 } 56 57 public ConnectorConnectionPool(int options) 58 { 59 super(comparators, runtimeVersion); 60 initPropertyTables(3); 62 this.createProperty("description", DESCRIPTION, 63 Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY, 64 String .class); 65 this.createProperty("security-map", SECURITY_MAP, 66 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 67 SecurityMap.class); 68 this.createAttribute(SECURITY_MAP, "name", "Name", 69 AttrProp.CDATA | AttrProp.REQUIRED, 70 null, null); 71 this.createProperty("property", ELEMENT_PROPERTY, 72 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 73 ElementProperty.class); 74 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 75 AttrProp.CDATA | AttrProp.REQUIRED, 76 null, null); 77 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 78 AttrProp.CDATA | AttrProp.REQUIRED, 79 null, null); 80 this.initialize(options); 81 } 82 83 void initialize(int options) { 85 86 } 87 88 91 public String getDescription() { 92 return (String ) getValue(ServerTags.DESCRIPTION); 93 } 94 98 public void setDescription(String v){ 99 setValue(ServerTags.DESCRIPTION, (null != v ? v.trim() : null)); 100 } 101 public void setSecurityMap(int index, SecurityMap value) { 103 this.setValue(SECURITY_MAP, index, value); 104 } 105 106 public SecurityMap getSecurityMap(int index) { 108 return (SecurityMap)this.getValue(SECURITY_MAP, index); 109 } 110 111 public void setSecurityMap(SecurityMap[] value) { 113 this.setValue(SECURITY_MAP, value); 114 } 115 116 public SecurityMap[] getSecurityMap() { 118 return (SecurityMap[])this.getValues(SECURITY_MAP); 119 } 120 121 public int sizeSecurityMap() { 123 return this.size(SECURITY_MAP); 124 } 125 126 public int addSecurityMap(SecurityMap value) 128 throws ConfigException{ 129 return addSecurityMap(value, true); 130 } 131 132 public int addSecurityMap(SecurityMap value, boolean overwrite) 134 throws ConfigException{ 135 SecurityMap old = getSecurityMapByName(value.getName()); 136 if(old != null) { 137 throw new ConfigException(StringManager.getManager(ConnectorConnectionPool.class).getString("cannotAddDuplicate", "SecurityMap")); 138 } 139 return this.addValue(SECURITY_MAP, value, overwrite); 140 } 141 142 public int removeSecurityMap(SecurityMap value){ 147 return this.removeValue(SECURITY_MAP, value); 148 } 149 150 public int removeSecurityMap(SecurityMap value, boolean overwrite) 156 throws StaleWriteConfigException{ 157 return this.removeValue(SECURITY_MAP, value, overwrite); 158 } 159 160 public SecurityMap getSecurityMapByName(String id) { 161 if (null != id) { id = id.trim(); } 162 SecurityMap[] o = getSecurityMap(); 163 if (o == null) return null; 164 165 for (int i=0; i < o.length; i++) { 166 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 167 return o[i]; 168 } 169 } 170 171 return null; 172 173 } 174 public void setElementProperty(int index, ElementProperty value) { 176 this.setValue(ELEMENT_PROPERTY, index, value); 177 } 178 179 public ElementProperty getElementProperty(int index) { 181 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 182 } 183 184 public void setElementProperty(ElementProperty[] value) { 186 this.setValue(ELEMENT_PROPERTY, value); 187 } 188 189 public ElementProperty[] getElementProperty() { 191 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 192 } 193 194 public int sizeElementProperty() { 196 return this.size(ELEMENT_PROPERTY); 197 } 198 199 public int addElementProperty(ElementProperty value) 201 throws ConfigException{ 202 return addElementProperty(value, true); 203 } 204 205 public int addElementProperty(ElementProperty value, boolean overwrite) 207 throws ConfigException{ 208 ElementProperty old = getElementPropertyByName(value.getName()); 209 if(old != null) { 210 throw new ConfigException(StringManager.getManager(ConnectorConnectionPool.class).getString("cannotAddDuplicate", "ElementProperty")); 211 } 212 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 213 } 214 215 public int removeElementProperty(ElementProperty value){ 220 return this.removeValue(ELEMENT_PROPERTY, value); 221 } 222 223 public int removeElementProperty(ElementProperty value, boolean overwrite) 229 throws StaleWriteConfigException{ 230 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 231 } 232 233 public ElementProperty getElementPropertyByName(String id) { 234 if (null != id) { id = id.trim(); } 235 ElementProperty[] o = getElementProperty(); 236 if (o == null) return null; 237 238 for (int i=0; i < o.length; i++) { 239 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 240 return o[i]; 241 } 242 } 243 244 return null; 245 246 } 247 251 public String getName() { 252 return getAttributeValue(ServerTags.NAME); 253 } 254 259 public void setName(String v, boolean overwrite) throws StaleWriteConfigException { 260 setAttributeValue(ServerTags.NAME, v, overwrite); 261 } 262 266 public void setName(String v) { 267 setAttributeValue(ServerTags.NAME, v); 268 } 269 273 public String getResourceAdapterName() { 274 return getAttributeValue(ServerTags.RESOURCE_ADAPTER_NAME); 275 } 276 281 public void setResourceAdapterName(String v, boolean overwrite) throws StaleWriteConfigException { 282 setAttributeValue(ServerTags.RESOURCE_ADAPTER_NAME, v, overwrite); 283 } 284 288 public void setResourceAdapterName(String v) { 289 setAttributeValue(ServerTags.RESOURCE_ADAPTER_NAME, v); 290 } 291 295 public String getConnectionDefinitionName() { 296 return getAttributeValue(ServerTags.CONNECTION_DEFINITION_NAME); 297 } 298 303 public void setConnectionDefinitionName(String v, boolean overwrite) throws StaleWriteConfigException { 304 setAttributeValue(ServerTags.CONNECTION_DEFINITION_NAME, v, overwrite); 305 } 306 310 public void setConnectionDefinitionName(String v) { 311 setAttributeValue(ServerTags.CONNECTION_DEFINITION_NAME, v); 312 } 313 317 public String getSteadyPoolSize() { 318 return getAttributeValue(ServerTags.STEADY_POOL_SIZE); 319 } 320 325 public void setSteadyPoolSize(String v, boolean overwrite) throws StaleWriteConfigException { 326 setAttributeValue(ServerTags.STEADY_POOL_SIZE, v, overwrite); 327 } 328 332 public void setSteadyPoolSize(String v) { 333 setAttributeValue(ServerTags.STEADY_POOL_SIZE, v); 334 } 335 338 public static String getDefaultSteadyPoolSize() { 339 return "8".trim(); 340 } 341 345 public String getMaxPoolSize() { 346 return getAttributeValue(ServerTags.MAX_POOL_SIZE); 347 } 348 353 public void setMaxPoolSize(String v, boolean overwrite) throws StaleWriteConfigException { 354 setAttributeValue(ServerTags.MAX_POOL_SIZE, v, overwrite); 355 } 356 360 public void setMaxPoolSize(String v) { 361 setAttributeValue(ServerTags.MAX_POOL_SIZE, v); 362 } 363 366 public static String getDefaultMaxPoolSize() { 367 return "32".trim(); 368 } 369 373 public String getMaxWaitTimeInMillis() { 374 return getAttributeValue(ServerTags.MAX_WAIT_TIME_IN_MILLIS); 375 } 376 381 public void setMaxWaitTimeInMillis(String v, boolean overwrite) throws StaleWriteConfigException { 382 setAttributeValue(ServerTags.MAX_WAIT_TIME_IN_MILLIS, v, overwrite); 383 } 384 388 public void setMaxWaitTimeInMillis(String v) { 389 setAttributeValue(ServerTags.MAX_WAIT_TIME_IN_MILLIS, v); 390 } 391 394 public static String getDefaultMaxWaitTimeInMillis() { 395 return "60000".trim(); 396 } 397 401 public String getPoolResizeQuantity() { 402 return getAttributeValue(ServerTags.POOL_RESIZE_QUANTITY); 403 } 404 409 public void setPoolResizeQuantity(String v, boolean overwrite) throws StaleWriteConfigException { 410 setAttributeValue(ServerTags.POOL_RESIZE_QUANTITY, v, overwrite); 411 } 412 416 public void setPoolResizeQuantity(String v) { 417 setAttributeValue(ServerTags.POOL_RESIZE_QUANTITY, v); 418 } 419 422 public static String getDefaultPoolResizeQuantity() { 423 return "2".trim(); 424 } 425 429 public String getIdleTimeoutInSeconds() { 430 return getAttributeValue(ServerTags.IDLE_TIMEOUT_IN_SECONDS); 431 } 432 437 public void setIdleTimeoutInSeconds(String v, boolean overwrite) throws StaleWriteConfigException { 438 setAttributeValue(ServerTags.IDLE_TIMEOUT_IN_SECONDS, v, overwrite); 439 } 440 444 public void setIdleTimeoutInSeconds(String v) { 445 setAttributeValue(ServerTags.IDLE_TIMEOUT_IN_SECONDS, v); 446 } 447 450 public static String getDefaultIdleTimeoutInSeconds() { 451 return "300".trim(); 452 } 453 457 public boolean isFailAllConnections() { 458 return toBoolean(getAttributeValue(ServerTags.FAIL_ALL_CONNECTIONS)); 459 } 460 465 public void setFailAllConnections(boolean v, boolean overwrite) throws StaleWriteConfigException { 466 setAttributeValue(ServerTags.FAIL_ALL_CONNECTIONS, ""+(v==true), overwrite); 467 } 468 472 public void setFailAllConnections(boolean v) { 473 setAttributeValue(ServerTags.FAIL_ALL_CONNECTIONS, ""+(v==true)); 474 } 475 478 public static String getDefaultFailAllConnections() { 479 return "false".trim(); 480 } 481 485 public String getTransactionSupport() { 486 return getAttributeValue(ServerTags.TRANSACTION_SUPPORT); 487 } 488 493 public void setTransactionSupport(String v, boolean overwrite) throws StaleWriteConfigException { 494 setAttributeValue(ServerTags.TRANSACTION_SUPPORT, v, overwrite); 495 } 496 500 public void setTransactionSupport(String v) { 501 setAttributeValue(ServerTags.TRANSACTION_SUPPORT, v); 502 } 503 507 public boolean isIsConnectionValidationRequired() { 508 return toBoolean(getAttributeValue(ServerTags.IS_CONNECTION_VALIDATION_REQUIRED)); 509 } 510 515 public void setIsConnectionValidationRequired(boolean v, boolean overwrite) throws StaleWriteConfigException { 516 setAttributeValue(ServerTags.IS_CONNECTION_VALIDATION_REQUIRED, ""+(v==true), overwrite); 517 } 518 522 public void setIsConnectionValidationRequired(boolean v) { 523 setAttributeValue(ServerTags.IS_CONNECTION_VALIDATION_REQUIRED, ""+(v==true)); 524 } 525 528 public static String getDefaultIsConnectionValidationRequired() { 529 return "false".trim(); 530 } 531 535 public SecurityMap newSecurityMap() { 536 return new SecurityMap(); 537 } 538 539 543 public ElementProperty newElementProperty() { 544 return new ElementProperty(); 545 } 546 547 552 protected String getRelativeXPath() { 553 String ret = null; 554 ret = "connector-connection-pool" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ; 555 return (null != ret ? ret.trim() : null); 556 } 557 558 561 public static String getDefaultAttributeValue(String attr) { 562 if(attr == null) return null; 563 attr = attr.trim(); 564 if(attr.equals(ServerTags.STEADY_POOL_SIZE)) return "8".trim(); 565 if(attr.equals(ServerTags.MAX_POOL_SIZE)) return "32".trim(); 566 if(attr.equals(ServerTags.MAX_WAIT_TIME_IN_MILLIS)) return "60000".trim(); 567 if(attr.equals(ServerTags.POOL_RESIZE_QUANTITY)) return "2".trim(); 568 if(attr.equals(ServerTags.IDLE_TIMEOUT_IN_SECONDS)) return "300".trim(); 569 if(attr.equals(ServerTags.FAIL_ALL_CONNECTIONS)) return "false".trim(); 570 if(attr.equals(ServerTags.IS_CONNECTION_VALIDATION_REQUIRED)) return "false".trim(); 571 return null; 572 } 573 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 575 comparators.add(c); 576 } 577 578 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 580 comparators.remove(c); 581 } 582 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 583 } 584 585 public void dump(StringBuffer str, String indent){ 587 String s; 588 Object o; 589 org.netbeans.modules.schema2beans.BaseBean n; 590 str.append(indent); 591 str.append("Description"); str.append(indent+"\t"); str.append("<"); o = this.getDescription(); 595 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(DESCRIPTION, 0, str, indent); 598 599 str.append(indent); 600 str.append("SecurityMap["+this.sizeSecurityMap()+"]"); for(int i=0; i<this.sizeSecurityMap(); i++) 602 { 603 str.append(indent+"\t"); 604 str.append("#"+i+":"); 605 n = (org.netbeans.modules.schema2beans.BaseBean) this.getSecurityMap(i); 606 if (n != null) 607 n.dump(str, indent + "\t"); else 609 str.append(indent+"\tnull"); this.dumpAttributes(SECURITY_MAP, i, str, indent); 611 } 612 613 str.append(indent); 614 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 616 { 617 str.append(indent+"\t"); 618 str.append("#"+i+":"); 619 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 620 if (n != null) 621 n.dump(str, indent + "\t"); else 623 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 625 } 626 627 } 628 public String dumpBeanNode(){ 629 StringBuffer str = new StringBuffer (); 630 str.append("ConnectorConnectionPool\n"); this.dump(str, "\n "); return str.toString(); 633 }} 634 635 637 | Popular Tags |