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 AvailabilityService 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 WEB_CONTAINER_AVAILABILITY = "WebContainerAvailability"; 50 static public final String EJB_CONTAINER_AVAILABILITY = "EjbContainerAvailability"; 51 static public final String JMS_AVAILABILITY = "JmsAvailability"; 52 static public final String ELEMENT_PROPERTY = "ElementProperty"; 53 54 public AvailabilityService() { 55 this(Common.USE_DEFAULT_VALUES); 56 } 57 58 public AvailabilityService(int options) 59 { 60 super(comparators, runtimeVersion); 61 initPropertyTables(4); 63 this.createProperty("web-container-availability", WEB_CONTAINER_AVAILABILITY, 64 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 65 WebContainerAvailability.class); 66 this.createAttribute(WEB_CONTAINER_AVAILABILITY, "availability-enabled", "AvailabilityEnabled", 67 AttrProp.CDATA | AttrProp.IMPLIED, 68 null, null); 69 this.createAttribute(WEB_CONTAINER_AVAILABILITY, "persistence-type", "PersistenceType", 70 AttrProp.CDATA, 71 null, "memory"); 72 this.createAttribute(WEB_CONTAINER_AVAILABILITY, "persistence-frequency", "PersistenceFrequency", 73 AttrProp.CDATA | AttrProp.IMPLIED, 74 null, null); 75 this.createAttribute(WEB_CONTAINER_AVAILABILITY, "persistence-scope", "PersistenceScope", 76 AttrProp.CDATA | AttrProp.IMPLIED, 77 null, null); 78 this.createAttribute(WEB_CONTAINER_AVAILABILITY, "persistence-store-health-check-enabled", "PersistenceStoreHealthCheckEnabled", 79 AttrProp.CDATA, 80 null, "false"); 81 this.createAttribute(WEB_CONTAINER_AVAILABILITY, "sso-failover-enabled", "SsoFailoverEnabled", 82 AttrProp.CDATA, 83 null, "false"); 84 this.createAttribute(WEB_CONTAINER_AVAILABILITY, "http-session-store-pool-name", "HttpSessionStorePoolName", 85 AttrProp.CDATA | AttrProp.IMPLIED, 86 null, null); 87 this.createProperty("ejb-container-availability", EJB_CONTAINER_AVAILABILITY, 88 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 89 EjbContainerAvailability.class); 90 this.createAttribute(EJB_CONTAINER_AVAILABILITY, "availability-enabled", "AvailabilityEnabled", 91 AttrProp.CDATA | AttrProp.IMPLIED, 92 null, null); 93 this.createAttribute(EJB_CONTAINER_AVAILABILITY, "sfsb-ha-persistence-type", "SfsbHaPersistenceType", 94 AttrProp.CDATA, 95 null, "ha"); 96 this.createAttribute(EJB_CONTAINER_AVAILABILITY, "sfsb-persistence-type", "SfsbPersistenceType", 97 AttrProp.CDATA, 98 null, "file"); 99 this.createAttribute(EJB_CONTAINER_AVAILABILITY, "sfsb-checkpoint-enabled", "SfsbCheckpointEnabled", 100 AttrProp.CDATA | AttrProp.IMPLIED, 101 null, null); 102 this.createAttribute(EJB_CONTAINER_AVAILABILITY, "sfsb-quick-checkpoint-enabled", "SfsbQuickCheckpointEnabled", 103 AttrProp.CDATA | AttrProp.IMPLIED, 104 null, null); 105 this.createAttribute(EJB_CONTAINER_AVAILABILITY, "sfsb-store-pool-name", "SfsbStorePoolName", 106 AttrProp.CDATA | AttrProp.IMPLIED, 107 null, null); 108 this.createProperty("jms-availability", JMS_AVAILABILITY, 109 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 110 JmsAvailability.class); 111 this.createAttribute(JMS_AVAILABILITY, "availability-enabled", "AvailabilityEnabled", 112 AttrProp.CDATA, 113 null, "false"); 114 this.createAttribute(JMS_AVAILABILITY, "mq-store-pool-name", "MqStorePoolName", 115 AttrProp.CDATA | AttrProp.IMPLIED, 116 null, null); 117 this.createProperty("property", ELEMENT_PROPERTY, 118 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 119 ElementProperty.class); 120 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 121 AttrProp.CDATA | AttrProp.REQUIRED, 122 null, null); 123 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 124 AttrProp.CDATA | AttrProp.REQUIRED, 125 null, null); 126 this.initialize(options); 127 } 128 129 void initialize(int options) { 131 132 } 133 134 public void setWebContainerAvailability(WebContainerAvailability value) { 136 this.setValue(WEB_CONTAINER_AVAILABILITY, value); 137 } 138 139 public WebContainerAvailability getWebContainerAvailability() { 141 return (WebContainerAvailability)this.getValue(WEB_CONTAINER_AVAILABILITY); 142 } 143 144 public void setEjbContainerAvailability(EjbContainerAvailability value) { 146 this.setValue(EJB_CONTAINER_AVAILABILITY, value); 147 } 148 149 public EjbContainerAvailability getEjbContainerAvailability() { 151 return (EjbContainerAvailability)this.getValue(EJB_CONTAINER_AVAILABILITY); 152 } 153 154 public void setJmsAvailability(JmsAvailability value) { 156 this.setValue(JMS_AVAILABILITY, value); 157 } 158 159 public JmsAvailability getJmsAvailability() { 161 return (JmsAvailability)this.getValue(JMS_AVAILABILITY); 162 } 163 164 public void setElementProperty(int index, ElementProperty value) { 166 this.setValue(ELEMENT_PROPERTY, index, value); 167 } 168 169 public ElementProperty getElementProperty(int index) { 171 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 172 } 173 174 public void setElementProperty(ElementProperty[] value) { 176 this.setValue(ELEMENT_PROPERTY, value); 177 } 178 179 public ElementProperty[] getElementProperty() { 181 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 182 } 183 184 public int sizeElementProperty() { 186 return this.size(ELEMENT_PROPERTY); 187 } 188 189 public int addElementProperty(ElementProperty value) 191 throws ConfigException{ 192 return addElementProperty(value, true); 193 } 194 195 public int addElementProperty(ElementProperty value, boolean overwrite) 197 throws ConfigException{ 198 ElementProperty old = getElementPropertyByName(value.getName()); 199 if(old != null) { 200 throw new ConfigException(StringManager.getManager(AvailabilityService.class).getString("cannotAddDuplicate", "ElementProperty")); 201 } 202 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 203 } 204 205 public int removeElementProperty(ElementProperty value){ 210 return this.removeValue(ELEMENT_PROPERTY, value); 211 } 212 213 public int removeElementProperty(ElementProperty value, boolean overwrite) 219 throws StaleWriteConfigException{ 220 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 221 } 222 223 public ElementProperty getElementPropertyByName(String id) { 224 if (null != id) { id = id.trim(); } 225 ElementProperty[] o = getElementProperty(); 226 if (o == null) return null; 227 228 for (int i=0; i < o.length; i++) { 229 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 230 return o[i]; 231 } 232 } 233 234 return null; 235 236 } 237 241 public boolean isAvailabilityEnabled() { 242 return toBoolean(getAttributeValue(ServerTags.AVAILABILITY_ENABLED)); 243 } 244 249 public void setAvailabilityEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 250 setAttributeValue(ServerTags.AVAILABILITY_ENABLED, ""+(v==true), overwrite); 251 } 252 256 public void setAvailabilityEnabled(boolean v) { 257 setAttributeValue(ServerTags.AVAILABILITY_ENABLED, ""+(v==true)); 258 } 259 262 public static String getDefaultAvailabilityEnabled() { 263 return "true".trim(); 264 } 265 269 public String getHaAgentHosts() { 270 return getAttributeValue(ServerTags.HA_AGENT_HOSTS); 271 } 272 277 public void setHaAgentHosts(String v, boolean overwrite) throws StaleWriteConfigException { 278 setAttributeValue(ServerTags.HA_AGENT_HOSTS, v, overwrite); 279 } 280 284 public void setHaAgentHosts(String v) { 285 setAttributeValue(ServerTags.HA_AGENT_HOSTS, v); 286 } 287 291 public String getHaAgentPort() { 292 return getAttributeValue(ServerTags.HA_AGENT_PORT); 293 } 294 299 public void setHaAgentPort(String v, boolean overwrite) throws StaleWriteConfigException { 300 setAttributeValue(ServerTags.HA_AGENT_PORT, v, overwrite); 301 } 302 306 public void setHaAgentPort(String v) { 307 setAttributeValue(ServerTags.HA_AGENT_PORT, v); 308 } 309 313 public String getHaAgentPassword() { 314 return getAttributeValue(ServerTags.HA_AGENT_PASSWORD); 315 } 316 321 public void setHaAgentPassword(String v, boolean overwrite) throws StaleWriteConfigException { 322 setAttributeValue(ServerTags.HA_AGENT_PASSWORD, v, overwrite); 323 } 324 328 public void setHaAgentPassword(String v) { 329 setAttributeValue(ServerTags.HA_AGENT_PASSWORD, v); 330 } 331 335 public String getHaStoreName() { 336 return getAttributeValue(ServerTags.HA_STORE_NAME); 337 } 338 343 public void setHaStoreName(String v, boolean overwrite) throws StaleWriteConfigException { 344 setAttributeValue(ServerTags.HA_STORE_NAME, v, overwrite); 345 } 346 350 public void setHaStoreName(String v) { 351 setAttributeValue(ServerTags.HA_STORE_NAME, v); 352 } 353 357 public boolean isAutoManageHaStore() { 358 return toBoolean(getAttributeValue(ServerTags.AUTO_MANAGE_HA_STORE)); 359 } 360 365 public void setAutoManageHaStore(boolean v, boolean overwrite) throws StaleWriteConfigException { 366 setAttributeValue(ServerTags.AUTO_MANAGE_HA_STORE, ""+(v==true), overwrite); 367 } 368 372 public void setAutoManageHaStore(boolean v) { 373 setAttributeValue(ServerTags.AUTO_MANAGE_HA_STORE, ""+(v==true)); 374 } 375 378 public static String getDefaultAutoManageHaStore() { 379 return "false".trim(); 380 } 381 385 public String getStorePoolName() { 386 return getAttributeValue(ServerTags.STORE_POOL_NAME); 387 } 388 393 public void setStorePoolName(String v, boolean overwrite) throws StaleWriteConfigException { 394 setAttributeValue(ServerTags.STORE_POOL_NAME, v, overwrite); 395 } 396 400 public void setStorePoolName(String v) { 401 setAttributeValue(ServerTags.STORE_POOL_NAME, v); 402 } 403 407 public boolean isHaStoreHealthcheckEnabled() { 408 return toBoolean(getAttributeValue(ServerTags.HA_STORE_HEALTHCHECK_ENABLED)); 409 } 410 415 public void setHaStoreHealthcheckEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 416 setAttributeValue(ServerTags.HA_STORE_HEALTHCHECK_ENABLED, ""+(v==true), overwrite); 417 } 418 422 public void setHaStoreHealthcheckEnabled(boolean v) { 423 setAttributeValue(ServerTags.HA_STORE_HEALTHCHECK_ENABLED, ""+(v==true)); 424 } 425 428 public static String getDefaultHaStoreHealthcheckEnabled() { 429 return "false".trim(); 430 } 431 435 public String getHaStoreHealthcheckIntervalInSeconds() { 436 return getAttributeValue(ServerTags.HA_STORE_HEALTHCHECK_INTERVAL_IN_SECONDS); 437 } 438 443 public void setHaStoreHealthcheckIntervalInSeconds(String v, boolean overwrite) throws StaleWriteConfigException { 444 setAttributeValue(ServerTags.HA_STORE_HEALTHCHECK_INTERVAL_IN_SECONDS, v, overwrite); 445 } 446 450 public void setHaStoreHealthcheckIntervalInSeconds(String v) { 451 setAttributeValue(ServerTags.HA_STORE_HEALTHCHECK_INTERVAL_IN_SECONDS, v); 452 } 453 456 public static String getDefaultHaStoreHealthcheckIntervalInSeconds() { 457 return "5".trim(); 458 } 459 463 public WebContainerAvailability newWebContainerAvailability() { 464 return new WebContainerAvailability(); 465 } 466 467 471 public EjbContainerAvailability newEjbContainerAvailability() { 472 return new EjbContainerAvailability(); 473 } 474 475 479 public JmsAvailability newJmsAvailability() { 480 return new JmsAvailability(); 481 } 482 483 487 public ElementProperty newElementProperty() { 488 return new ElementProperty(); 489 } 490 491 496 protected String getRelativeXPath() { 497 String ret = null; 498 ret = "availability-service"; 499 return (null != ret ? ret.trim() : null); 500 } 501 502 505 public static String getDefaultAttributeValue(String attr) { 506 if(attr == null) return null; 507 attr = attr.trim(); 508 if(attr.equals(ServerTags.AVAILABILITY_ENABLED)) return "true".trim(); 509 if(attr.equals(ServerTags.AUTO_MANAGE_HA_STORE)) return "false".trim(); 510 if(attr.equals(ServerTags.HA_STORE_HEALTHCHECK_ENABLED)) return "false".trim(); 511 if(attr.equals(ServerTags.HA_STORE_HEALTHCHECK_INTERVAL_IN_SECONDS)) return "5".trim(); 512 return null; 513 } 514 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 516 comparators.add(c); 517 } 518 519 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 521 comparators.remove(c); 522 } 523 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 524 } 525 526 public void dump(StringBuffer str, String indent){ 528 String s; 529 Object o; 530 org.netbeans.modules.schema2beans.BaseBean n; 531 str.append(indent); 532 str.append("WebContainerAvailability"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getWebContainerAvailability(); 534 if (n != null) 535 n.dump(str, indent + "\t"); else 537 str.append(indent+"\tnull"); this.dumpAttributes(WEB_CONTAINER_AVAILABILITY, 0, str, indent); 539 540 str.append(indent); 541 str.append("EjbContainerAvailability"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getEjbContainerAvailability(); 543 if (n != null) 544 n.dump(str, indent + "\t"); else 546 str.append(indent+"\tnull"); this.dumpAttributes(EJB_CONTAINER_AVAILABILITY, 0, str, indent); 548 549 str.append(indent); 550 str.append("JmsAvailability"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getJmsAvailability(); 552 if (n != null) 553 n.dump(str, indent + "\t"); else 555 str.append(indent+"\tnull"); this.dumpAttributes(JMS_AVAILABILITY, 0, str, indent); 557 558 str.append(indent); 559 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 561 { 562 str.append(indent+"\t"); 563 str.append("#"+i+":"); 564 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 565 if (n != null) 566 n.dump(str, indent + "\t"); else 568 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 570 } 571 572 } 573 public String dumpBeanNode(){ 574 StringBuffer str = new StringBuffer (); 575 str.append("AvailabilityService\n"); this.dump(str, "\n "); return str.toString(); 578 }} 579 580 582 | Popular Tags |