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 LoadBalancers 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 LOAD_BALANCER = "LoadBalancer"; 50 51 public LoadBalancers() { 52 this(Common.USE_DEFAULT_VALUES); 53 } 54 55 public LoadBalancers(int options) 56 { 57 super(comparators, runtimeVersion); 58 initPropertyTables(1); 60 this.createProperty("load-balancer", LOAD_BALANCER, 61 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 62 LoadBalancer.class); 63 this.createAttribute(LOAD_BALANCER, "name", "Name", 64 AttrProp.CDATA | AttrProp.REQUIRED, 65 null, null); 66 this.createAttribute(LOAD_BALANCER, "lb-config-name", "LbConfigName", 67 AttrProp.CDATA | AttrProp.REQUIRED, 68 null, null); 69 this.createAttribute(LOAD_BALANCER, "auto-apply-enabled", "AutoApplyEnabled", 70 AttrProp.CDATA, 71 null, "false"); 72 this.initialize(options); 73 } 74 75 void initialize(int options) { 77 78 } 79 80 public void setLoadBalancer(int index, LoadBalancer value) { 82 this.setValue(LOAD_BALANCER, index, value); 83 } 84 85 public LoadBalancer getLoadBalancer(int index) { 87 return (LoadBalancer)this.getValue(LOAD_BALANCER, index); 88 } 89 90 public void setLoadBalancer(LoadBalancer[] value) { 92 this.setValue(LOAD_BALANCER, value); 93 } 94 95 public LoadBalancer[] getLoadBalancer() { 97 return (LoadBalancer[])this.getValues(LOAD_BALANCER); 98 } 99 100 public int sizeLoadBalancer() { 102 return this.size(LOAD_BALANCER); 103 } 104 105 public int addLoadBalancer(LoadBalancer value) 107 throws ConfigException{ 108 return addLoadBalancer(value, true); 109 } 110 111 public int addLoadBalancer(LoadBalancer value, boolean overwrite) 113 throws ConfigException{ 114 LoadBalancer old = getLoadBalancerByName(value.getName()); 115 if(old != null) { 116 throw new ConfigException(StringManager.getManager(LoadBalancers.class).getString("cannotAddDuplicate", "LoadBalancer")); 117 } 118 return this.addValue(LOAD_BALANCER, value, overwrite); 119 } 120 121 public int removeLoadBalancer(LoadBalancer value){ 126 return this.removeValue(LOAD_BALANCER, value); 127 } 128 129 public int removeLoadBalancer(LoadBalancer value, boolean overwrite) 135 throws StaleWriteConfigException{ 136 return this.removeValue(LOAD_BALANCER, value, overwrite); 137 } 138 139 public LoadBalancer getLoadBalancerByName(String id) { 140 if (null != id) { id = id.trim(); } 141 LoadBalancer[] o = getLoadBalancer(); 142 if (o == null) return null; 143 144 for (int i=0; i < o.length; i++) { 145 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 146 return o[i]; 147 } 148 } 149 150 return null; 151 152 } 153 157 public LoadBalancer newLoadBalancer() { 158 return new LoadBalancer(); 159 } 160 161 166 protected String getRelativeXPath() { 167 String ret = null; 168 ret = "load-balancers"; 169 return (null != ret ? ret.trim() : null); 170 } 171 172 175 public static String getDefaultAttributeValue(String attr) { 176 if(attr == null) return null; 177 attr = attr.trim(); 178 return null; 179 } 180 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 182 comparators.add(c); 183 } 184 185 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 187 comparators.remove(c); 188 } 189 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 190 } 191 192 public void dump(StringBuffer str, String indent){ 194 String s; 195 Object o; 196 org.netbeans.modules.schema2beans.BaseBean n; 197 str.append(indent); 198 str.append("LoadBalancer["+this.sizeLoadBalancer()+"]"); for(int i=0; i<this.sizeLoadBalancer(); i++) 200 { 201 str.append(indent+"\t"); 202 str.append("#"+i+":"); 203 n = (org.netbeans.modules.schema2beans.BaseBean) this.getLoadBalancer(i); 204 if (n != null) 205 n.dump(str, indent + "\t"); else 207 str.append(indent+"\tnull"); this.dumpAttributes(LOAD_BALANCER, i, str, indent); 209 } 210 211 } 212 public String dumpBeanNode(){ 213 StringBuffer str = new StringBuffer (); 214 str.append("LoadBalancers\n"); this.dump(str, "\n "); return str.toString(); 217 }} 218 219 221 | Popular Tags |