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 ClusterRef 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 ClusterRef() { 52 this(Common.USE_DEFAULT_VALUES); 53 } 54 55 public ClusterRef(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 getLbPolicy() { 117 return getAttributeValue(ServerTags.LB_POLICY); 118 } 119 124 public void setLbPolicy(String v, boolean overwrite) throws StaleWriteConfigException { 125 setAttributeValue(ServerTags.LB_POLICY, v, overwrite); 126 } 127 131 public void setLbPolicy(String v) { 132 setAttributeValue(ServerTags.LB_POLICY, v); 133 } 134 137 public static String getDefaultLbPolicy() { 138 return "round-robin".trim(); 139 } 140 144 public String getLbPolicyModule() { 145 return getAttributeValue(ServerTags.LB_POLICY_MODULE); 146 } 147 152 public void setLbPolicyModule(String v, boolean overwrite) throws StaleWriteConfigException { 153 setAttributeValue(ServerTags.LB_POLICY_MODULE, v, overwrite); 154 } 155 159 public void setLbPolicyModule(String v) { 160 setAttributeValue(ServerTags.LB_POLICY_MODULE, v); 161 } 162 166 public HealthChecker newHealthChecker() { 167 return new HealthChecker(); 168 } 169 170 175 protected String getRelativeXPath() { 176 String ret = null; 177 ret = "cluster-ref" + (canHaveSiblings() ? "[@ref='" + getAttributeValue("ref") +"']" : "") ; 178 return (null != ret ? ret.trim() : null); 179 } 180 181 184 public static String getDefaultAttributeValue(String attr) { 185 if(attr == null) return null; 186 attr = attr.trim(); 187 if(attr.equals(ServerTags.LB_POLICY)) return "round-robin".trim(); 188 return null; 189 } 190 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 192 comparators.add(c); 193 } 194 195 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 197 comparators.remove(c); 198 } 199 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 200 } 201 202 public void dump(StringBuffer str, String indent){ 204 String s; 205 Object o; 206 org.netbeans.modules.schema2beans.BaseBean n; 207 str.append(indent); 208 str.append("HealthChecker"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getHealthChecker(); 210 if (n != null) 211 n.dump(str, indent + "\t"); else 213 str.append(indent+"\tnull"); this.dumpAttributes(HEALTH_CHECKER, 0, str, indent); 215 216 } 217 public String dumpBeanNode(){ 218 StringBuffer str = new StringBuffer (); 219 str.append("ClusterRef\n"); this.dump(str, "\n "); return str.toString(); 222 }} 223 224 226 | Popular Tags |