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 Servers 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 SERVER = "Server"; 50 51 public Servers() { 52 this(Common.USE_DEFAULT_VALUES); 53 } 54 55 public Servers(int options) 56 { 57 super(comparators, runtimeVersion); 58 initPropertyTables(1); 60 this.createProperty("server", SERVER, 61 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 62 Server.class); 63 this.createAttribute(SERVER, "name", "Name", 64 AttrProp.CDATA | AttrProp.REQUIRED, 65 null, null); 66 this.createAttribute(SERVER, "config-ref", "ConfigRef", 67 AttrProp.CDATA | AttrProp.IMPLIED, 68 null, null); 69 this.createAttribute(SERVER, "node-agent-ref", "NodeAgentRef", 70 AttrProp.CDATA | AttrProp.IMPLIED, 71 null, null); 72 this.createAttribute(SERVER, "lb-weight", "LbWeight", 73 AttrProp.CDATA, 74 null, "100"); 75 this.initialize(options); 76 } 77 78 void initialize(int options) { 80 81 } 82 83 public void setServer(int index, Server value) { 85 this.setValue(SERVER, index, value); 86 } 87 88 public Server getServer(int index) { 90 return (Server)this.getValue(SERVER, index); 91 } 92 93 public void setServer(Server[] value) { 95 this.setValue(SERVER, value); 96 } 97 98 public Server[] getServer() { 100 return (Server[])this.getValues(SERVER); 101 } 102 103 public int sizeServer() { 105 return this.size(SERVER); 106 } 107 108 public int addServer(Server value) 110 throws ConfigException{ 111 return addServer(value, true); 112 } 113 114 public int addServer(Server value, boolean overwrite) 116 throws ConfigException{ 117 Server old = getServerByName(value.getName()); 118 if(old != null) { 119 throw new ConfigException(StringManager.getManager(Servers.class).getString("cannotAddDuplicate", "Server")); 120 } 121 return this.addValue(SERVER, value, overwrite); 122 } 123 124 public int removeServer(Server value){ 129 return this.removeValue(SERVER, value); 130 } 131 132 public int removeServer(Server value, boolean overwrite) 138 throws StaleWriteConfigException{ 139 return this.removeValue(SERVER, value, overwrite); 140 } 141 142 public Server getServerByName(String id) { 143 if (null != id) { id = id.trim(); } 144 Server[] o = getServer(); 145 if (o == null) return null; 146 147 for (int i=0; i < o.length; i++) { 148 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 149 return o[i]; 150 } 151 } 152 153 return null; 154 155 } 156 160 public Server newServer() { 161 return new Server(); 162 } 163 164 169 protected String getRelativeXPath() { 170 String ret = null; 171 ret = "servers"; 172 return (null != ret ? ret.trim() : null); 173 } 174 175 178 public static String getDefaultAttributeValue(String attr) { 179 if(attr == null) return null; 180 attr = attr.trim(); 181 return null; 182 } 183 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 185 comparators.add(c); 186 } 187 188 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 190 comparators.remove(c); 191 } 192 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 193 } 194 195 public void dump(StringBuffer str, String indent){ 197 String s; 198 Object o; 199 org.netbeans.modules.schema2beans.BaseBean n; 200 str.append(indent); 201 str.append("Server["+this.sizeServer()+"]"); for(int i=0; i<this.sizeServer(); i++) 203 { 204 str.append(indent+"\t"); 205 str.append("#"+i+":"); 206 n = (org.netbeans.modules.schema2beans.BaseBean) this.getServer(i); 207 if (n != null) 208 n.dump(str, indent + "\t"); else 210 str.append(indent+"\tnull"); this.dumpAttributes(SERVER, i, str, indent); 212 } 213 214 } 215 public String dumpBeanNode(){ 216 StringBuffer str = new StringBuffer (); 217 str.append("Servers\n"); this.dump(str, "\n "); return str.toString(); 220 }} 221 222 224 | Popular Tags |