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 DasConfig 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 ELEMENT_PROPERTY = "ElementProperty"; 50 51 public DasConfig() { 52 this(Common.USE_DEFAULT_VALUES); 53 } 54 55 public DasConfig(int options) 56 { 57 super(comparators, runtimeVersion); 58 initPropertyTables(1); 60 this.createProperty("property", ELEMENT_PROPERTY, 61 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 62 ElementProperty.class); 63 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 64 AttrProp.CDATA | AttrProp.REQUIRED, 65 null, null); 66 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 67 AttrProp.CDATA | AttrProp.REQUIRED, 68 null, null); 69 this.initialize(options); 70 } 71 72 void initialize(int options) { 74 75 } 76 77 public void setElementProperty(int index, ElementProperty value) { 79 this.setValue(ELEMENT_PROPERTY, index, value); 80 } 81 82 public ElementProperty getElementProperty(int index) { 84 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 85 } 86 87 public void setElementProperty(ElementProperty[] value) { 89 this.setValue(ELEMENT_PROPERTY, value); 90 } 91 92 public ElementProperty[] getElementProperty() { 94 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 95 } 96 97 public int sizeElementProperty() { 99 return this.size(ELEMENT_PROPERTY); 100 } 101 102 public int addElementProperty(ElementProperty value) 104 throws ConfigException{ 105 return addElementProperty(value, true); 106 } 107 108 public int addElementProperty(ElementProperty value, boolean overwrite) 110 throws ConfigException{ 111 ElementProperty old = getElementPropertyByName(value.getName()); 112 if(old != null) { 113 throw new ConfigException(StringManager.getManager(DasConfig.class).getString("cannotAddDuplicate", "ElementProperty")); 114 } 115 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 116 } 117 118 public int removeElementProperty(ElementProperty value){ 123 return this.removeValue(ELEMENT_PROPERTY, value); 124 } 125 126 public int removeElementProperty(ElementProperty value, boolean overwrite) 132 throws StaleWriteConfigException{ 133 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 134 } 135 136 public ElementProperty getElementPropertyByName(String id) { 137 if (null != id) { id = id.trim(); } 138 ElementProperty[] o = getElementProperty(); 139 if (o == null) return null; 140 141 for (int i=0; i < o.length; i++) { 142 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 143 return o[i]; 144 } 145 } 146 147 return null; 148 149 } 150 154 public boolean isDynamicReloadEnabled() { 155 return toBoolean(getAttributeValue(ServerTags.DYNAMIC_RELOAD_ENABLED)); 156 } 157 162 public void setDynamicReloadEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 163 setAttributeValue(ServerTags.DYNAMIC_RELOAD_ENABLED, ""+(v==true), overwrite); 164 } 165 169 public void setDynamicReloadEnabled(boolean v) { 170 setAttributeValue(ServerTags.DYNAMIC_RELOAD_ENABLED, ""+(v==true)); 171 } 172 175 public static String getDefaultDynamicReloadEnabled() { 176 return "false".trim(); 177 } 178 182 public String getDynamicReloadPollIntervalInSeconds() { 183 return getAttributeValue(ServerTags.DYNAMIC_RELOAD_POLL_INTERVAL_IN_SECONDS); 184 } 185 190 public void setDynamicReloadPollIntervalInSeconds(String v, boolean overwrite) throws StaleWriteConfigException { 191 setAttributeValue(ServerTags.DYNAMIC_RELOAD_POLL_INTERVAL_IN_SECONDS, v, overwrite); 192 } 193 197 public void setDynamicReloadPollIntervalInSeconds(String v) { 198 setAttributeValue(ServerTags.DYNAMIC_RELOAD_POLL_INTERVAL_IN_SECONDS, v); 199 } 200 203 public static String getDefaultDynamicReloadPollIntervalInSeconds() { 204 return "2".trim(); 205 } 206 210 public boolean isAutodeployEnabled() { 211 return toBoolean(getAttributeValue(ServerTags.AUTODEPLOY_ENABLED)); 212 } 213 218 public void setAutodeployEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 219 setAttributeValue(ServerTags.AUTODEPLOY_ENABLED, ""+(v==true), overwrite); 220 } 221 225 public void setAutodeployEnabled(boolean v) { 226 setAttributeValue(ServerTags.AUTODEPLOY_ENABLED, ""+(v==true)); 227 } 228 231 public static String getDefaultAutodeployEnabled() { 232 return "false".trim(); 233 } 234 238 public String getAutodeployPollingIntervalInSeconds() { 239 return getAttributeValue(ServerTags.AUTODEPLOY_POLLING_INTERVAL_IN_SECONDS); 240 } 241 246 public void setAutodeployPollingIntervalInSeconds(String v, boolean overwrite) throws StaleWriteConfigException { 247 setAttributeValue(ServerTags.AUTODEPLOY_POLLING_INTERVAL_IN_SECONDS, v, overwrite); 248 } 249 253 public void setAutodeployPollingIntervalInSeconds(String v) { 254 setAttributeValue(ServerTags.AUTODEPLOY_POLLING_INTERVAL_IN_SECONDS, v); 255 } 256 259 public static String getDefaultAutodeployPollingIntervalInSeconds() { 260 return "2".trim(); 261 } 262 266 public String getAutodeployDir() { 267 return getAttributeValue(ServerTags.AUTODEPLOY_DIR); 268 } 269 274 public void setAutodeployDir(String v, boolean overwrite) throws StaleWriteConfigException { 275 setAttributeValue(ServerTags.AUTODEPLOY_DIR, v, overwrite); 276 } 277 281 public void setAutodeployDir(String v) { 282 setAttributeValue(ServerTags.AUTODEPLOY_DIR, v); 283 } 284 287 public static String getDefaultAutodeployDir() { 288 return "autodeploy".trim(); 289 } 290 294 public boolean isAutodeployVerifierEnabled() { 295 return toBoolean(getAttributeValue(ServerTags.AUTODEPLOY_VERIFIER_ENABLED)); 296 } 297 302 public void setAutodeployVerifierEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 303 setAttributeValue(ServerTags.AUTODEPLOY_VERIFIER_ENABLED, ""+(v==true), overwrite); 304 } 305 309 public void setAutodeployVerifierEnabled(boolean v) { 310 setAttributeValue(ServerTags.AUTODEPLOY_VERIFIER_ENABLED, ""+(v==true)); 311 } 312 315 public static String getDefaultAutodeployVerifierEnabled() { 316 return "false".trim(); 317 } 318 322 public boolean isAutodeployJspPrecompilationEnabled() { 323 return toBoolean(getAttributeValue(ServerTags.AUTODEPLOY_JSP_PRECOMPILATION_ENABLED)); 324 } 325 330 public void setAutodeployJspPrecompilationEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 331 setAttributeValue(ServerTags.AUTODEPLOY_JSP_PRECOMPILATION_ENABLED, ""+(v==true), overwrite); 332 } 333 337 public void setAutodeployJspPrecompilationEnabled(boolean v) { 338 setAttributeValue(ServerTags.AUTODEPLOY_JSP_PRECOMPILATION_ENABLED, ""+(v==true)); 339 } 340 343 public static String getDefaultAutodeployJspPrecompilationEnabled() { 344 return "false".trim(); 345 } 346 350 public String getDeployXmlValidation() { 351 return getAttributeValue(ServerTags.DEPLOY_XML_VALIDATION); 352 } 353 358 public void setDeployXmlValidation(String v, boolean overwrite) throws StaleWriteConfigException { 359 setAttributeValue(ServerTags.DEPLOY_XML_VALIDATION, v, overwrite); 360 } 361 365 public void setDeployXmlValidation(String v) { 366 setAttributeValue(ServerTags.DEPLOY_XML_VALIDATION, v); 367 } 368 371 public static String getDefaultDeployXmlValidation() { 372 return "full".trim(); 373 } 374 378 public String getAdminSessionTimeoutInMinutes() { 379 return getAttributeValue(ServerTags.ADMIN_SESSION_TIMEOUT_IN_MINUTES); 380 } 381 386 public void setAdminSessionTimeoutInMinutes(String v, boolean overwrite) throws StaleWriteConfigException { 387 setAttributeValue(ServerTags.ADMIN_SESSION_TIMEOUT_IN_MINUTES, v, overwrite); 388 } 389 393 public void setAdminSessionTimeoutInMinutes(String v) { 394 setAttributeValue(ServerTags.ADMIN_SESSION_TIMEOUT_IN_MINUTES, v); 395 } 396 399 public static String getDefaultAdminSessionTimeoutInMinutes() { 400 return "60".trim(); 401 } 402 406 public ElementProperty newElementProperty() { 407 return new ElementProperty(); 408 } 409 410 415 protected String getRelativeXPath() { 416 String ret = null; 417 ret = "das-config"; 418 return (null != ret ? ret.trim() : null); 419 } 420 421 424 public static String getDefaultAttributeValue(String attr) { 425 if(attr == null) return null; 426 attr = attr.trim(); 427 if(attr.equals(ServerTags.DYNAMIC_RELOAD_ENABLED)) return "false".trim(); 428 if(attr.equals(ServerTags.DYNAMIC_RELOAD_POLL_INTERVAL_IN_SECONDS)) return "2".trim(); 429 if(attr.equals(ServerTags.AUTODEPLOY_ENABLED)) return "false".trim(); 430 if(attr.equals(ServerTags.AUTODEPLOY_POLLING_INTERVAL_IN_SECONDS)) return "2".trim(); 431 if(attr.equals(ServerTags.AUTODEPLOY_DIR)) return "autodeploy".trim(); 432 if(attr.equals(ServerTags.AUTODEPLOY_VERIFIER_ENABLED)) return "false".trim(); 433 if(attr.equals(ServerTags.AUTODEPLOY_JSP_PRECOMPILATION_ENABLED)) return "false".trim(); 434 if(attr.equals(ServerTags.DEPLOY_XML_VALIDATION)) return "full".trim(); 435 if(attr.equals(ServerTags.ADMIN_SESSION_TIMEOUT_IN_MINUTES)) return "60".trim(); 436 return null; 437 } 438 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 440 comparators.add(c); 441 } 442 443 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 445 comparators.remove(c); 446 } 447 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 448 } 449 450 public void dump(StringBuffer str, String indent){ 452 String s; 453 Object o; 454 org.netbeans.modules.schema2beans.BaseBean n; 455 str.append(indent); 456 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 458 { 459 str.append(indent+"\t"); 460 str.append("#"+i+":"); 461 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 462 if (n != null) 463 n.dump(str, indent + "\t"); else 465 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 467 } 468 469 } 470 public String dumpBeanNode(){ 471 StringBuffer str = new StringBuffer (); 472 str.append("DasConfig\n"); this.dump(str, "\n "); return str.toString(); 475 }} 476 477 479 | Popular Tags |