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 EjbContainer 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 EJB_TIMER_SERVICE = "EjbTimerService"; 50 static public final String ELEMENT_PROPERTY = "ElementProperty"; 51 52 public EjbContainer() { 53 this(Common.USE_DEFAULT_VALUES); 54 } 55 56 public EjbContainer(int options) 57 { 58 super(comparators, runtimeVersion); 59 initPropertyTables(2); 61 this.createProperty("ejb-timer-service", EJB_TIMER_SERVICE, 62 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 63 EjbTimerService.class); 64 this.createAttribute(EJB_TIMER_SERVICE, "minimum-delivery-interval-in-millis", "MinimumDeliveryIntervalInMillis", 65 AttrProp.CDATA, 66 null, "7000"); 67 this.createAttribute(EJB_TIMER_SERVICE, "max-redeliveries", "MaxRedeliveries", 68 AttrProp.CDATA, 69 null, "1"); 70 this.createAttribute(EJB_TIMER_SERVICE, "timer-datasource", "TimerDatasource", 71 AttrProp.CDATA | AttrProp.IMPLIED, 72 null, null); 73 this.createAttribute(EJB_TIMER_SERVICE, "redelivery-interval-internal-in-millis", "RedeliveryIntervalInternalInMillis", 74 AttrProp.CDATA, 75 null, "5000"); 76 this.createProperty("property", ELEMENT_PROPERTY, 77 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 78 ElementProperty.class); 79 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 80 AttrProp.CDATA | AttrProp.REQUIRED, 81 null, null); 82 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 83 AttrProp.CDATA | AttrProp.REQUIRED, 84 null, null); 85 this.initialize(options); 86 } 87 88 void initialize(int options) { 90 91 } 92 93 public void setEjbTimerService(EjbTimerService value) { 95 this.setValue(EJB_TIMER_SERVICE, value); 96 } 97 98 public EjbTimerService getEjbTimerService() { 100 return (EjbTimerService)this.getValue(EJB_TIMER_SERVICE); 101 } 102 103 public void setElementProperty(int index, ElementProperty value) { 105 this.setValue(ELEMENT_PROPERTY, index, value); 106 } 107 108 public ElementProperty getElementProperty(int index) { 110 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 111 } 112 113 public void setElementProperty(ElementProperty[] value) { 115 this.setValue(ELEMENT_PROPERTY, value); 116 } 117 118 public ElementProperty[] getElementProperty() { 120 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 121 } 122 123 public int sizeElementProperty() { 125 return this.size(ELEMENT_PROPERTY); 126 } 127 128 public int addElementProperty(ElementProperty value) 130 throws ConfigException{ 131 return addElementProperty(value, true); 132 } 133 134 public int addElementProperty(ElementProperty value, boolean overwrite) 136 throws ConfigException{ 137 ElementProperty old = getElementPropertyByName(value.getName()); 138 if(old != null) { 139 throw new ConfigException(StringManager.getManager(EjbContainer.class).getString("cannotAddDuplicate", "ElementProperty")); 140 } 141 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 142 } 143 144 public int removeElementProperty(ElementProperty value){ 149 return this.removeValue(ELEMENT_PROPERTY, value); 150 } 151 152 public int removeElementProperty(ElementProperty value, boolean overwrite) 158 throws StaleWriteConfigException{ 159 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 160 } 161 162 public ElementProperty getElementPropertyByName(String id) { 163 if (null != id) { id = id.trim(); } 164 ElementProperty[] o = getElementProperty(); 165 if (o == null) return null; 166 167 for (int i=0; i < o.length; i++) { 168 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 169 return o[i]; 170 } 171 } 172 173 return null; 174 175 } 176 180 public String getSteadyPoolSize() { 181 return getAttributeValue(ServerTags.STEADY_POOL_SIZE); 182 } 183 188 public void setSteadyPoolSize(String v, boolean overwrite) throws StaleWriteConfigException { 189 setAttributeValue(ServerTags.STEADY_POOL_SIZE, v, overwrite); 190 } 191 195 public void setSteadyPoolSize(String v) { 196 setAttributeValue(ServerTags.STEADY_POOL_SIZE, v); 197 } 198 201 public static String getDefaultSteadyPoolSize() { 202 return "32".trim(); 203 } 204 208 public String getPoolResizeQuantity() { 209 return getAttributeValue(ServerTags.POOL_RESIZE_QUANTITY); 210 } 211 216 public void setPoolResizeQuantity(String v, boolean overwrite) throws StaleWriteConfigException { 217 setAttributeValue(ServerTags.POOL_RESIZE_QUANTITY, v, overwrite); 218 } 219 223 public void setPoolResizeQuantity(String v) { 224 setAttributeValue(ServerTags.POOL_RESIZE_QUANTITY, v); 225 } 226 229 public static String getDefaultPoolResizeQuantity() { 230 return "16".trim(); 231 } 232 236 public String getMaxPoolSize() { 237 return getAttributeValue(ServerTags.MAX_POOL_SIZE); 238 } 239 244 public void setMaxPoolSize(String v, boolean overwrite) throws StaleWriteConfigException { 245 setAttributeValue(ServerTags.MAX_POOL_SIZE, v, overwrite); 246 } 247 251 public void setMaxPoolSize(String v) { 252 setAttributeValue(ServerTags.MAX_POOL_SIZE, v); 253 } 254 257 public static String getDefaultMaxPoolSize() { 258 return "64".trim(); 259 } 260 264 public String getCacheResizeQuantity() { 265 return getAttributeValue(ServerTags.CACHE_RESIZE_QUANTITY); 266 } 267 272 public void setCacheResizeQuantity(String v, boolean overwrite) throws StaleWriteConfigException { 273 setAttributeValue(ServerTags.CACHE_RESIZE_QUANTITY, v, overwrite); 274 } 275 279 public void setCacheResizeQuantity(String v) { 280 setAttributeValue(ServerTags.CACHE_RESIZE_QUANTITY, v); 281 } 282 285 public static String getDefaultCacheResizeQuantity() { 286 return "32".trim(); 287 } 288 292 public String getMaxCacheSize() { 293 return getAttributeValue(ServerTags.MAX_CACHE_SIZE); 294 } 295 300 public void setMaxCacheSize(String v, boolean overwrite) throws StaleWriteConfigException { 301 setAttributeValue(ServerTags.MAX_CACHE_SIZE, v, overwrite); 302 } 303 307 public void setMaxCacheSize(String v) { 308 setAttributeValue(ServerTags.MAX_CACHE_SIZE, v); 309 } 310 313 public static String getDefaultMaxCacheSize() { 314 return "512".trim(); 315 } 316 320 public String getPoolIdleTimeoutInSeconds() { 321 return getAttributeValue(ServerTags.POOL_IDLE_TIMEOUT_IN_SECONDS); 322 } 323 328 public void setPoolIdleTimeoutInSeconds(String v, boolean overwrite) throws StaleWriteConfigException { 329 setAttributeValue(ServerTags.POOL_IDLE_TIMEOUT_IN_SECONDS, v, overwrite); 330 } 331 335 public void setPoolIdleTimeoutInSeconds(String v) { 336 setAttributeValue(ServerTags.POOL_IDLE_TIMEOUT_IN_SECONDS, v); 337 } 338 341 public static String getDefaultPoolIdleTimeoutInSeconds() { 342 return "600".trim(); 343 } 344 348 public String getCacheIdleTimeoutInSeconds() { 349 return getAttributeValue(ServerTags.CACHE_IDLE_TIMEOUT_IN_SECONDS); 350 } 351 356 public void setCacheIdleTimeoutInSeconds(String v, boolean overwrite) throws StaleWriteConfigException { 357 setAttributeValue(ServerTags.CACHE_IDLE_TIMEOUT_IN_SECONDS, v, overwrite); 358 } 359 363 public void setCacheIdleTimeoutInSeconds(String v) { 364 setAttributeValue(ServerTags.CACHE_IDLE_TIMEOUT_IN_SECONDS, v); 365 } 366 369 public static String getDefaultCacheIdleTimeoutInSeconds() { 370 return "600".trim(); 371 } 372 376 public String getRemovalTimeoutInSeconds() { 377 return getAttributeValue(ServerTags.REMOVAL_TIMEOUT_IN_SECONDS); 378 } 379 384 public void setRemovalTimeoutInSeconds(String v, boolean overwrite) throws StaleWriteConfigException { 385 setAttributeValue(ServerTags.REMOVAL_TIMEOUT_IN_SECONDS, v, overwrite); 386 } 387 391 public void setRemovalTimeoutInSeconds(String v) { 392 setAttributeValue(ServerTags.REMOVAL_TIMEOUT_IN_SECONDS, v); 393 } 394 397 public static String getDefaultRemovalTimeoutInSeconds() { 398 return "5400".trim(); 399 } 400 404 public String getVictimSelectionPolicy() { 405 return getAttributeValue(ServerTags.VICTIM_SELECTION_POLICY); 406 } 407 412 public void setVictimSelectionPolicy(String v, boolean overwrite) throws StaleWriteConfigException { 413 setAttributeValue(ServerTags.VICTIM_SELECTION_POLICY, v, overwrite); 414 } 415 419 public void setVictimSelectionPolicy(String v) { 420 setAttributeValue(ServerTags.VICTIM_SELECTION_POLICY, v); 421 } 422 425 public static String getDefaultVictimSelectionPolicy() { 426 return "nru".trim(); 427 } 428 432 public String getCommitOption() { 433 return getAttributeValue(ServerTags.COMMIT_OPTION); 434 } 435 440 public void setCommitOption(String v, boolean overwrite) throws StaleWriteConfigException { 441 setAttributeValue(ServerTags.COMMIT_OPTION, v, overwrite); 442 } 443 447 public void setCommitOption(String v) { 448 setAttributeValue(ServerTags.COMMIT_OPTION, v); 449 } 450 453 public static String getDefaultCommitOption() { 454 return "B".trim(); 455 } 456 460 public String getSessionStore() { 461 return getAttributeValue(ServerTags.SESSION_STORE); 462 } 463 468 public void setSessionStore(String v, boolean overwrite) throws StaleWriteConfigException { 469 setAttributeValue(ServerTags.SESSION_STORE, v, overwrite); 470 } 471 475 public void setSessionStore(String v) { 476 setAttributeValue(ServerTags.SESSION_STORE, v); 477 } 478 482 public EjbTimerService newEjbTimerService() { 483 return new EjbTimerService(); 484 } 485 486 490 public ElementProperty newElementProperty() { 491 return new ElementProperty(); 492 } 493 494 499 protected String getRelativeXPath() { 500 String ret = null; 501 ret = "ejb-container"; 502 return (null != ret ? ret.trim() : null); 503 } 504 505 508 public static String getDefaultAttributeValue(String attr) { 509 if(attr == null) return null; 510 attr = attr.trim(); 511 if(attr.equals(ServerTags.STEADY_POOL_SIZE)) return "32".trim(); 512 if(attr.equals(ServerTags.POOL_RESIZE_QUANTITY)) return "16".trim(); 513 if(attr.equals(ServerTags.MAX_POOL_SIZE)) return "64".trim(); 514 if(attr.equals(ServerTags.CACHE_RESIZE_QUANTITY)) return "32".trim(); 515 if(attr.equals(ServerTags.MAX_CACHE_SIZE)) return "512".trim(); 516 if(attr.equals(ServerTags.POOL_IDLE_TIMEOUT_IN_SECONDS)) return "600".trim(); 517 if(attr.equals(ServerTags.CACHE_IDLE_TIMEOUT_IN_SECONDS)) return "600".trim(); 518 if(attr.equals(ServerTags.REMOVAL_TIMEOUT_IN_SECONDS)) return "5400".trim(); 519 if(attr.equals(ServerTags.VICTIM_SELECTION_POLICY)) return "nru".trim(); 520 if(attr.equals(ServerTags.COMMIT_OPTION)) return "B".trim(); 521 return null; 522 } 523 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 525 comparators.add(c); 526 } 527 528 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 530 comparators.remove(c); 531 } 532 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 533 } 534 535 public void dump(StringBuffer str, String indent){ 537 String s; 538 Object o; 539 org.netbeans.modules.schema2beans.BaseBean n; 540 str.append(indent); 541 str.append("EjbTimerService"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getEjbTimerService(); 543 if (n != null) 544 n.dump(str, indent + "\t"); else 546 str.append(indent+"\tnull"); this.dumpAttributes(EJB_TIMER_SERVICE, 0, str, indent); 548 549 str.append(indent); 550 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 552 { 553 str.append(indent+"\t"); 554 str.append("#"+i+":"); 555 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 556 if (n != null) 557 n.dump(str, indent + "\t"); else 559 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 561 } 562 563 } 564 public String dumpBeanNode(){ 565 StringBuffer str = new StringBuffer (); 566 str.append("EjbContainer\n"); this.dump(str, "\n "); return str.toString(); 569 }} 570 571 573 | Popular Tags |