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 ServerRef 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 HEALTH_CHECKER = "HealthChecker"; 50 51 public ServerRef() { 52 this(Common.USE_DEFAULT_VALUES); 53 } 54 55 public ServerRef(int options) 56 { 57 super(comparators, runtimeVersion); 58 initPropertyTables(1); 60 this.createProperty("health-checker", HEALTH_CHECKER, 61 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 62 HealthChecker.class); 63 this.createAttribute(HEALTH_CHECKER, "url", "Url", 64 AttrProp.CDATA, 65 null, "/"); 66 this.createAttribute(HEALTH_CHECKER, "interval-in-seconds", "IntervalInSeconds", 67 AttrProp.CDATA, 68 null, "30"); 69 this.createAttribute(HEALTH_CHECKER, "timeout-in-seconds", "TimeoutInSeconds", 70 AttrProp.CDATA, 71 null, "10"); 72 this.initialize(options); 73 } 74 75 void initialize(int options) { 77 78 } 79 80 public void setHealthChecker(HealthChecker value) { 82 this.setValue(HEALTH_CHECKER, value); 83 } 84 85 public HealthChecker getHealthChecker() { 87 return (HealthChecker)this.getValue(HEALTH_CHECKER); 88 } 89 90 94 public String getRef() { 95 return getAttributeValue(ServerTags.REF); 96 } 97 102 public void setRef(String v, boolean overwrite) throws StaleWriteConfigException { 103 setAttributeValue(ServerTags.REF, v, overwrite); 104 } 105 109 public void setRef(String v) { 110 setAttributeValue(ServerTags.REF, v); 111 } 112 116 public String getDisableTimeoutInMinutes() { 117 return getAttributeValue(ServerTags.DISABLE_TIMEOUT_IN_MINUTES); 118 } 119 124 public void setDisableTimeoutInMinutes(String v, boolean overwrite) throws StaleWriteConfigException { 125 setAttributeValue(ServerTags.DISABLE_TIMEOUT_IN_MINUTES, v, overwrite); 126 } 127 131 public void setDisableTimeoutInMinutes(String v) { 132 setAttributeValue(ServerTags.DISABLE_TIMEOUT_IN_MINUTES, v); 133 } 134 137 public static String getDefaultDisableTimeoutInMinutes() { 138 return "30".trim(); 139 } 140 144 public boolean isLbEnabled() { 145 return toBoolean(getAttributeValue(ServerTags.LB_ENABLED)); 146 } 147 152 public void setLbEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 153 setAttributeValue(ServerTags.LB_ENABLED, ""+(v==true), overwrite); 154 } 155 159 public void setLbEnabled(boolean v) { 160 setAttributeValue(ServerTags.LB_ENABLED, ""+(v==true)); 161 } 162 165 public static String getDefaultLbEnabled() { 166 return "false".trim(); 167 } 168 172 public boolean isEnabled() { 173 return toBoolean(getAttributeValue(ServerTags.ENABLED)); 174 } 175 180 public void setEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 181 setAttributeValue(ServerTags.ENABLED, ""+(v==true), overwrite); 182 } 183 187 public void setEnabled(boolean v) { 188 setAttributeValue(ServerTags.ENABLED, ""+(v==true)); 189 } 190 193 public static String getDefaultEnabled() { 194 return "true".trim(); 195 } 196 200 public HealthChecker newHealthChecker() { 201 return new HealthChecker(); 202 } 203 204 209 protected String getRelativeXPath() { 210 String ret = null; 211 ret = "server-ref" + (canHaveSiblings() ? "[@ref='" + getAttributeValue("ref") +"']" : "") ; 212 return (null != ret ? ret.trim() : null); 213 } 214 215 218 public static String getDefaultAttributeValue(String attr) { 219 if(attr == null) return null; 220 attr = attr.trim(); 221 if(attr.equals(ServerTags.DISABLE_TIMEOUT_IN_MINUTES)) return "30".trim(); 222 if(attr.equals(ServerTags.LB_ENABLED)) return "false".trim(); 223 if(attr.equals(ServerTags.ENABLED)) return "true".trim(); 224 return null; 225 } 226 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 228 comparators.add(c); 229 } 230 231 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 233 comparators.remove(c); 234 } 235 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 236 } 237 238 public void dump(StringBuffer str, String indent){ 240 String s; 241 Object o; 242 org.netbeans.modules.schema2beans.BaseBean n; 243 str.append(indent); 244 str.append("HealthChecker"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getHealthChecker(); 246 if (n != null) 247 n.dump(str, indent + "\t"); else 249 str.append(indent+"\tnull"); this.dumpAttributes(HEALTH_CHECKER, 0, str, indent); 251 252 } 253 public String dumpBeanNode(){ 254 StringBuffer str = new StringBuffer (); 255 str.append("ServerRef\n"); this.dump(str, "\n "); return str.toString(); 258 }} 259 260 262 | Popular Tags |