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 JdbcConnectionPool 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 ELEMENT_PROPERTY = "ElementProperty"; 51 52 public JdbcConnectionPool() { 53 this(Common.USE_DEFAULT_VALUES); 54 } 55 56 public JdbcConnectionPool(int options) 57 { 58 super(comparators, runtimeVersion); 59 initPropertyTables(2); 61 this.createProperty("description", DESCRIPTION, 62 Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY, 63 String .class); 64 this.createProperty("property", ELEMENT_PROPERTY, 65 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 66 ElementProperty.class); 67 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 68 AttrProp.CDATA | AttrProp.REQUIRED, 69 null, null); 70 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 71 AttrProp.CDATA | AttrProp.REQUIRED, 72 null, null); 73 this.initialize(options); 74 } 75 76 void initialize(int options) { 78 79 } 80 81 84 public String getDescription() { 85 return (String ) getValue(ServerTags.DESCRIPTION); 86 } 87 91 public void setDescription(String v){ 92 setValue(ServerTags.DESCRIPTION, (null != v ? v.trim() : null)); 93 } 94 public void setElementProperty(int index, ElementProperty value) { 96 this.setValue(ELEMENT_PROPERTY, index, value); 97 } 98 99 public ElementProperty getElementProperty(int index) { 101 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 102 } 103 104 public void setElementProperty(ElementProperty[] value) { 106 this.setValue(ELEMENT_PROPERTY, value); 107 } 108 109 public ElementProperty[] getElementProperty() { 111 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 112 } 113 114 public int sizeElementProperty() { 116 return this.size(ELEMENT_PROPERTY); 117 } 118 119 public int addElementProperty(ElementProperty value) 121 throws ConfigException{ 122 return addElementProperty(value, true); 123 } 124 125 public int addElementProperty(ElementProperty value, boolean overwrite) 127 throws ConfigException{ 128 ElementProperty old = getElementPropertyByName(value.getName()); 129 if(old != null) { 130 throw new ConfigException(StringManager.getManager(JdbcConnectionPool.class).getString("cannotAddDuplicate", "ElementProperty")); 131 } 132 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 133 } 134 135 public int removeElementProperty(ElementProperty value){ 140 return this.removeValue(ELEMENT_PROPERTY, value); 141 } 142 143 public int removeElementProperty(ElementProperty value, boolean overwrite) 149 throws StaleWriteConfigException{ 150 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 151 } 152 153 public ElementProperty getElementPropertyByName(String id) { 154 if (null != id) { id = id.trim(); } 155 ElementProperty[] o = getElementProperty(); 156 if (o == null) return null; 157 158 for (int i=0; i < o.length; i++) { 159 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 160 return o[i]; 161 } 162 } 163 164 return null; 165 166 } 167 171 public String getName() { 172 return getAttributeValue(ServerTags.NAME); 173 } 174 179 public void setName(String v, boolean overwrite) throws StaleWriteConfigException { 180 setAttributeValue(ServerTags.NAME, v, overwrite); 181 } 182 186 public void setName(String v) { 187 setAttributeValue(ServerTags.NAME, v); 188 } 189 193 public String getDatasourceClassname() { 194 return getAttributeValue(ServerTags.DATASOURCE_CLASSNAME); 195 } 196 201 public void setDatasourceClassname(String v, boolean overwrite) throws StaleWriteConfigException { 202 setAttributeValue(ServerTags.DATASOURCE_CLASSNAME, v, overwrite); 203 } 204 208 public void setDatasourceClassname(String v) { 209 setAttributeValue(ServerTags.DATASOURCE_CLASSNAME, v); 210 } 211 215 public String getResType() { 216 return getAttributeValue(ServerTags.RES_TYPE); 217 } 218 223 public void setResType(String v, boolean overwrite) throws StaleWriteConfigException { 224 setAttributeValue(ServerTags.RES_TYPE, v, overwrite); 225 } 226 230 public void setResType(String v) { 231 setAttributeValue(ServerTags.RES_TYPE, v); 232 } 233 237 public String getSteadyPoolSize() { 238 return getAttributeValue(ServerTags.STEADY_POOL_SIZE); 239 } 240 245 public void setSteadyPoolSize(String v, boolean overwrite) throws StaleWriteConfigException { 246 setAttributeValue(ServerTags.STEADY_POOL_SIZE, v, overwrite); 247 } 248 252 public void setSteadyPoolSize(String v) { 253 setAttributeValue(ServerTags.STEADY_POOL_SIZE, v); 254 } 255 258 public static String getDefaultSteadyPoolSize() { 259 return "8".trim(); 260 } 261 265 public String getMaxPoolSize() { 266 return getAttributeValue(ServerTags.MAX_POOL_SIZE); 267 } 268 273 public void setMaxPoolSize(String v, boolean overwrite) throws StaleWriteConfigException { 274 setAttributeValue(ServerTags.MAX_POOL_SIZE, v, overwrite); 275 } 276 280 public void setMaxPoolSize(String v) { 281 setAttributeValue(ServerTags.MAX_POOL_SIZE, v); 282 } 283 286 public static String getDefaultMaxPoolSize() { 287 return "32".trim(); 288 } 289 293 public String getMaxWaitTimeInMillis() { 294 return getAttributeValue(ServerTags.MAX_WAIT_TIME_IN_MILLIS); 295 } 296 301 public void setMaxWaitTimeInMillis(String v, boolean overwrite) throws StaleWriteConfigException { 302 setAttributeValue(ServerTags.MAX_WAIT_TIME_IN_MILLIS, v, overwrite); 303 } 304 308 public void setMaxWaitTimeInMillis(String v) { 309 setAttributeValue(ServerTags.MAX_WAIT_TIME_IN_MILLIS, v); 310 } 311 314 public static String getDefaultMaxWaitTimeInMillis() { 315 return "60000".trim(); 316 } 317 321 public String getPoolResizeQuantity() { 322 return getAttributeValue(ServerTags.POOL_RESIZE_QUANTITY); 323 } 324 329 public void setPoolResizeQuantity(String v, boolean overwrite) throws StaleWriteConfigException { 330 setAttributeValue(ServerTags.POOL_RESIZE_QUANTITY, v, overwrite); 331 } 332 336 public void setPoolResizeQuantity(String v) { 337 setAttributeValue(ServerTags.POOL_RESIZE_QUANTITY, v); 338 } 339 342 public static String getDefaultPoolResizeQuantity() { 343 return "2".trim(); 344 } 345 349 public String getIdleTimeoutInSeconds() { 350 return getAttributeValue(ServerTags.IDLE_TIMEOUT_IN_SECONDS); 351 } 352 357 public void setIdleTimeoutInSeconds(String v, boolean overwrite) throws StaleWriteConfigException { 358 setAttributeValue(ServerTags.IDLE_TIMEOUT_IN_SECONDS, v, overwrite); 359 } 360 364 public void setIdleTimeoutInSeconds(String v) { 365 setAttributeValue(ServerTags.IDLE_TIMEOUT_IN_SECONDS, v); 366 } 367 370 public static String getDefaultIdleTimeoutInSeconds() { 371 return "300".trim(); 372 } 373 377 public String getTransactionIsolationLevel() { 378 return getAttributeValue(ServerTags.TRANSACTION_ISOLATION_LEVEL); 379 } 380 385 public void setTransactionIsolationLevel(String v, boolean overwrite) throws StaleWriteConfigException { 386 setAttributeValue(ServerTags.TRANSACTION_ISOLATION_LEVEL, v, overwrite); 387 } 388 392 public void setTransactionIsolationLevel(String v) { 393 setAttributeValue(ServerTags.TRANSACTION_ISOLATION_LEVEL, v); 394 } 395 399 public boolean isIsIsolationLevelGuaranteed() { 400 return toBoolean(getAttributeValue(ServerTags.IS_ISOLATION_LEVEL_GUARANTEED)); 401 } 402 407 public void setIsIsolationLevelGuaranteed(boolean v, boolean overwrite) throws StaleWriteConfigException { 408 setAttributeValue(ServerTags.IS_ISOLATION_LEVEL_GUARANTEED, ""+(v==true), overwrite); 409 } 410 414 public void setIsIsolationLevelGuaranteed(boolean v) { 415 setAttributeValue(ServerTags.IS_ISOLATION_LEVEL_GUARANTEED, ""+(v==true)); 416 } 417 420 public static String getDefaultIsIsolationLevelGuaranteed() { 421 return "true".trim(); 422 } 423 427 public boolean isIsConnectionValidationRequired() { 428 return toBoolean(getAttributeValue(ServerTags.IS_CONNECTION_VALIDATION_REQUIRED)); 429 } 430 435 public void setIsConnectionValidationRequired(boolean v, boolean overwrite) throws StaleWriteConfigException { 436 setAttributeValue(ServerTags.IS_CONNECTION_VALIDATION_REQUIRED, ""+(v==true), overwrite); 437 } 438 442 public void setIsConnectionValidationRequired(boolean v) { 443 setAttributeValue(ServerTags.IS_CONNECTION_VALIDATION_REQUIRED, ""+(v==true)); 444 } 445 448 public static String getDefaultIsConnectionValidationRequired() { 449 return "false".trim(); 450 } 451 455 public String getConnectionValidationMethod() { 456 return getAttributeValue(ServerTags.CONNECTION_VALIDATION_METHOD); 457 } 458 463 public void setConnectionValidationMethod(String v, boolean overwrite) throws StaleWriteConfigException { 464 setAttributeValue(ServerTags.CONNECTION_VALIDATION_METHOD, v, overwrite); 465 } 466 470 public void setConnectionValidationMethod(String v) { 471 setAttributeValue(ServerTags.CONNECTION_VALIDATION_METHOD, v); 472 } 473 476 public static String getDefaultConnectionValidationMethod() { 477 return "auto-commit".trim(); 478 } 479 483 public String getValidationTableName() { 484 return getAttributeValue(ServerTags.VALIDATION_TABLE_NAME); 485 } 486 491 public void setValidationTableName(String v, boolean overwrite) throws StaleWriteConfigException { 492 setAttributeValue(ServerTags.VALIDATION_TABLE_NAME, v, overwrite); 493 } 494 498 public void setValidationTableName(String v) { 499 setAttributeValue(ServerTags.VALIDATION_TABLE_NAME, v); 500 } 501 505 public boolean isFailAllConnections() { 506 return toBoolean(getAttributeValue(ServerTags.FAIL_ALL_CONNECTIONS)); 507 } 508 513 public void setFailAllConnections(boolean v, boolean overwrite) throws StaleWriteConfigException { 514 setAttributeValue(ServerTags.FAIL_ALL_CONNECTIONS, ""+(v==true), overwrite); 515 } 516 520 public void setFailAllConnections(boolean v) { 521 setAttributeValue(ServerTags.FAIL_ALL_CONNECTIONS, ""+(v==true)); 522 } 523 526 public static String getDefaultFailAllConnections() { 527 return "false".trim(); 528 } 529 533 public boolean isNonTransactionalConnections() { 534 return toBoolean(getAttributeValue(ServerTags.NON_TRANSACTIONAL_CONNECTIONS)); 535 } 536 541 public void setNonTransactionalConnections(boolean v, boolean overwrite) throws StaleWriteConfigException { 542 setAttributeValue(ServerTags.NON_TRANSACTIONAL_CONNECTIONS, ""+(v==true), overwrite); 543 } 544 548 public void setNonTransactionalConnections(boolean v) { 549 setAttributeValue(ServerTags.NON_TRANSACTIONAL_CONNECTIONS, ""+(v==true)); 550 } 551 554 public static String getDefaultNonTransactionalConnections() { 555 return "false".trim(); 556 } 557 561 public boolean isAllowNonComponentCallers() { 562 return toBoolean(getAttributeValue(ServerTags.ALLOW_NON_COMPONENT_CALLERS)); 563 } 564 569 public void setAllowNonComponentCallers(boolean v, boolean overwrite) throws StaleWriteConfigException { 570 setAttributeValue(ServerTags.ALLOW_NON_COMPONENT_CALLERS, ""+(v==true), overwrite); 571 } 572 576 public void setAllowNonComponentCallers(boolean v) { 577 setAttributeValue(ServerTags.ALLOW_NON_COMPONENT_CALLERS, ""+(v==true)); 578 } 579 582 public static String getDefaultAllowNonComponentCallers() { 583 return "false".trim(); 584 } 585 589 public ElementProperty newElementProperty() { 590 return new ElementProperty(); 591 } 592 593 598 protected String getRelativeXPath() { 599 String ret = null; 600 ret = "jdbc-connection-pool" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ; 601 return (null != ret ? ret.trim() : null); 602 } 603 604 607 public static String getDefaultAttributeValue(String attr) { 608 if(attr == null) return null; 609 attr = attr.trim(); 610 if(attr.equals(ServerTags.STEADY_POOL_SIZE)) return "8".trim(); 611 if(attr.equals(ServerTags.MAX_POOL_SIZE)) return "32".trim(); 612 if(attr.equals(ServerTags.MAX_WAIT_TIME_IN_MILLIS)) return "60000".trim(); 613 if(attr.equals(ServerTags.POOL_RESIZE_QUANTITY)) return "2".trim(); 614 if(attr.equals(ServerTags.IDLE_TIMEOUT_IN_SECONDS)) return "300".trim(); 615 if(attr.equals(ServerTags.IS_ISOLATION_LEVEL_GUARANTEED)) return "true".trim(); 616 if(attr.equals(ServerTags.IS_CONNECTION_VALIDATION_REQUIRED)) return "false".trim(); 617 if(attr.equals(ServerTags.CONNECTION_VALIDATION_METHOD)) return "auto-commit".trim(); 618 if(attr.equals(ServerTags.FAIL_ALL_CONNECTIONS)) return "false".trim(); 619 if(attr.equals(ServerTags.NON_TRANSACTIONAL_CONNECTIONS)) return "false".trim(); 620 if(attr.equals(ServerTags.ALLOW_NON_COMPONENT_CALLERS)) return "false".trim(); 621 return null; 622 } 623 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 625 comparators.add(c); 626 } 627 628 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 630 comparators.remove(c); 631 } 632 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 633 } 634 635 public void dump(StringBuffer str, String indent){ 637 String s; 638 Object o; 639 org.netbeans.modules.schema2beans.BaseBean n; 640 str.append(indent); 641 str.append("Description"); str.append(indent+"\t"); str.append("<"); o = this.getDescription(); 645 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(DESCRIPTION, 0, str, indent); 648 649 str.append(indent); 650 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 652 { 653 str.append(indent+"\t"); 654 str.append("#"+i+":"); 655 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 656 if (n != null) 657 n.dump(str, indent + "\t"); else 659 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 661 } 662 663 } 664 public String dumpBeanNode(){ 665 StringBuffer str = new StringBuffer (); 666 str.append("JdbcConnectionPool\n"); this.dump(str, "\n "); return str.toString(); 669 }} 670 671 673 | Popular Tags |