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 Clusters 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 CLUSTER = "Cluster"; 50 51 public Clusters() { 52 this(Common.USE_DEFAULT_VALUES); 53 } 54 55 public Clusters(int options) 56 { 57 super(comparators, runtimeVersion); 58 initPropertyTables(1); 60 this.createProperty("cluster", CLUSTER, 61 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 62 Cluster.class); 63 this.createAttribute(CLUSTER, "name", "Name", 64 AttrProp.CDATA | AttrProp.REQUIRED, 65 null, null); 66 this.createAttribute(CLUSTER, "config-ref", "ConfigRef", 67 AttrProp.CDATA | AttrProp.REQUIRED, 68 null, null); 69 this.createAttribute(CLUSTER, "heartbeat-port", "HeartbeatPort", 70 AttrProp.CDATA | AttrProp.REQUIRED, 71 null, null); 72 this.createAttribute(CLUSTER, "heartbeat-address", "HeartbeatAddress", 73 AttrProp.CDATA | AttrProp.REQUIRED, 74 null, null); 75 this.createAttribute(CLUSTER, "heartbeat-enabled", "HeartbeatEnabled", 76 AttrProp.CDATA, 77 null, "true"); 78 this.initialize(options); 79 } 80 81 void initialize(int options) { 83 84 } 85 86 public void setCluster(int index, Cluster value) { 88 this.setValue(CLUSTER, index, value); 89 } 90 91 public Cluster getCluster(int index) { 93 return (Cluster)this.getValue(CLUSTER, index); 94 } 95 96 public void setCluster(Cluster[] value) { 98 this.setValue(CLUSTER, value); 99 } 100 101 public Cluster[] getCluster() { 103 return (Cluster[])this.getValues(CLUSTER); 104 } 105 106 public int sizeCluster() { 108 return this.size(CLUSTER); 109 } 110 111 public int addCluster(Cluster value) 113 throws ConfigException{ 114 return addCluster(value, true); 115 } 116 117 public int addCluster(Cluster value, boolean overwrite) 119 throws ConfigException{ 120 Cluster old = getClusterByName(value.getName()); 121 if(old != null) { 122 throw new ConfigException(StringManager.getManager(Clusters.class).getString("cannotAddDuplicate", "Cluster")); 123 } 124 return this.addValue(CLUSTER, value, overwrite); 125 } 126 127 public int removeCluster(Cluster value){ 132 return this.removeValue(CLUSTER, value); 133 } 134 135 public int removeCluster(Cluster value, boolean overwrite) 141 throws StaleWriteConfigException{ 142 return this.removeValue(CLUSTER, value, overwrite); 143 } 144 145 public Cluster getClusterByName(String id) { 146 if (null != id) { id = id.trim(); } 147 Cluster[] o = getCluster(); 148 if (o == null) return null; 149 150 for (int i=0; i < o.length; i++) { 151 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 152 return o[i]; 153 } 154 } 155 156 return null; 157 158 } 159 163 public Cluster newCluster() { 164 return new Cluster(); 165 } 166 167 172 protected String getRelativeXPath() { 173 String ret = null; 174 ret = "clusters"; 175 return (null != ret ? ret.trim() : null); 176 } 177 178 181 public static String getDefaultAttributeValue(String attr) { 182 if(attr == null) return null; 183 attr = attr.trim(); 184 return null; 185 } 186 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 188 comparators.add(c); 189 } 190 191 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 193 comparators.remove(c); 194 } 195 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 196 } 197 198 public void dump(StringBuffer str, String indent){ 200 String s; 201 Object o; 202 org.netbeans.modules.schema2beans.BaseBean n; 203 str.append(indent); 204 str.append("Cluster["+this.sizeCluster()+"]"); for(int i=0; i<this.sizeCluster(); i++) 206 { 207 str.append(indent+"\t"); 208 str.append("#"+i+":"); 209 n = (org.netbeans.modules.schema2beans.BaseBean) this.getCluster(i); 210 if (n != null) 211 n.dump(str, indent + "\t"); else 213 str.append(indent+"\tnull"); this.dumpAttributes(CLUSTER, i, str, indent); 215 } 216 217 } 218 public String dumpBeanNode(){ 219 StringBuffer str = new StringBuffer (); 220 str.append("Clusters\n"); this.dump(str, "\n "); return str.toString(); 223 }} 224 225 227 | Popular Tags |